cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Attaching Sharepoint Attachments to Email

Hello,

I am trying to attach a attachment from sharepoint to an email everytime a attachment is created or modified but the flow keeps failing at the email part.

 

Capture.PNGCapture1.PNG

I keep getting this error everytime the flow runs.

Capture3.PNG

What am I doing wrong? 

 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Attaching Sharepoint Attachments to Email

Hi @chartergrowth,

 

I think there is something wrong with the Compose action within your flow, the Attachment Content dynamic content and the DisplayName dynamic content should not be wrapped with double quotes.

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created or modified" trigger, specify Site Address and List Name.
  • Add a "Get attachments" action, specify Site Address and List name, Id field set to ID dynamic content of the trigger.
  • Add a Variables-> "Initialize variable" action, Name set to AttachmentArray, Type set to Array and Value set to empty.
  • Add a "Apply to each" action, input parameter set to output of "Get attachments" action.
  • Within "Apply to each" action, add a "Get attachment content" action, specify Site Address and List Name, Id field set to ID dynamic content of the trigger, File Identifier field set to Id dynamic content of the "Get attachments" action.

         Add a "Append to array variable" action, Name choose AttachmentArray, Value set to following json data formula:8.JPGWithin above json data, there are two elements. The key of first element set to Name and corresponding value set to DisplayName dynamic content. The key of second element set to ContentBytes and corresponding value set to following formula:

body('Get_attachment_content')?['$content']
  • Under "Apply to each" action, add a "Send an email" action, Attachments field set to AttachmentArray variable, Is HTML set to Yes.

Image reference:9.JPG

 

10.JPG

The flow works successfully as below:11.JPG

 

12.JPG

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Highlighted
Community Support
Community Support

Re: Attaching Sharepoint Attachments to Email

Hi @chartergrowth,

 

I think there is something wrong with the Compose action within your flow, the Attachment Content dynamic content and the DisplayName dynamic content should not be wrapped with double quotes.

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created or modified" trigger, specify Site Address and List Name.
  • Add a "Get attachments" action, specify Site Address and List name, Id field set to ID dynamic content of the trigger.
  • Add a Variables-> "Initialize variable" action, Name set to AttachmentArray, Type set to Array and Value set to empty.
  • Add a "Apply to each" action, input parameter set to output of "Get attachments" action.
  • Within "Apply to each" action, add a "Get attachment content" action, specify Site Address and List Name, Id field set to ID dynamic content of the trigger, File Identifier field set to Id dynamic content of the "Get attachments" action.

         Add a "Append to array variable" action, Name choose AttachmentArray, Value set to following json data formula:8.JPGWithin above json data, there are two elements. The key of first element set to Name and corresponding value set to DisplayName dynamic content. The key of second element set to ContentBytes and corresponding value set to following formula:

body('Get_attachment_content')?['$content']
  • Under "Apply to each" action, add a "Send an email" action, Attachments field set to AttachmentArray variable, Is HTML set to Yes.

Image reference:9.JPG

 

10.JPG

The flow works successfully as below:11.JPG

 

12.JPG

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: Attaching Sharepoint Attachments to Email

Hi,

Thanks for you help. I had to make a couple of changes to what you posted above but it is now working!

 

Another quick thing. I tried adding a create file in Box action to my flow but it doesn't give me the option to add the variable content. I tried adding the function variable('AtachmentArray'). The flow runs and succeeds but the file that shows up in box says that the document type is not supported and when I download it, I just get a bunch of code. How can I get the variable attachment to work?

 

Thanks.

Highlighted

Re: Attaching Sharepoint Attachments to Email

Hello,

 

I follow your instructions and the flow doesn't work. The flow checker asks me to enter a valid json while I put the same function as you.

 

Best regards,

Alexandre.

Highlighted

Re: Attaching Sharepoint Attachments to Email

I found my mistake, I forgot the comma to the function json.

 

Thank you for your help,

Alexandre.

Highlighted
Regular Visitor

Re: Attaching Sharepoint Attachments to Email

I've got a Flow set up if not exactly like yours Kris, it is very similar and it completes with an email being sent but I'm not seeing the attachments that are with the list item. Any thoughts on why this is happening? 

I can see the Attachments when looking at the Flow run with names like 

"[\n\"Name\" Travis Test Build - App List Template.xlsx\n\"ConentBytes\" UEsDBBQABgAIAAAAIQDh...... But they are not in the email.

 

Highlighted
Advocate III
Advocate III

Re: Attaching Sharepoint Attachments to Email

I'm struggling to get this same thing to work on my Flow. I have a PowerApp set up to collect Employee Action Forms from my operations team. An HTML template and some replace() in a number of composes I've gotten it to create a PDF to send the form to HR. The sharepoint list does allow for attachments (appraisals and docs to accompany any promotion or increase) but I'm not able to get the additional documents to attach with the Action Form.

 

attachVar.jpg

I went thru the array variable but can't get it to end up attaching to the email. I'm running the Compose to union attachements from 2 different locations. Any help is appreciated:

 

PDFAttach: creates the object to later be in a CreateArray() in the union

GetEmailBody: Template HTML email file for the body of the email. Simplified message editing

Initialize the Variable:

Condition: If the Sharepoint list item has an attachement then it sends all attachements, if it doesn't is sends the original attachement.

Get Attachement:

Apply to each:

AttachUnion: The union() that combines the variables and the orginal attachment.

Email

 

Everything succeeds in the Flow but there is not attachment to the email when it comes across.

Highlighted
Regular Visitor

Re: Attaching Sharepoint Attachments to Email

Thank you for the instructions for creating the flow. 

 

I got the flow to succeed, but the attachment in the email is not readable. It just shows list of codes which is not the content of the original file attached in the Sharepoint list. Please help. Thanks

 

 

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (4,388)