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

Using an array to attach multiple files to an email in flow

I've been working on this for quite some time and seem to be spinning my wheels. I've reviewed a number of posts for this same type of issue and can't seem to find the correct solution.  I have a flow that reads file contents using a file path and puts the name and content information into an array.  However, when I attempt to attach the array to an email the email comes through with no attachments.

 

Please see the attached screen shots.

flowscreenshot1flowscreenshot1Flowscreenshot2Flowscreenshot2

Results in the following

Flowresultsscreenshot2Flowresultsscreenshot2flowresultsscreenshot1flowresultsscreenshot1

 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

I finally figured out the magic.  Instead of attempting to only insert the file information I inserted the full File Content variable and then all worked wonderfully.

Here's my final screen shot for what worked in my append to array information.

 

append to array final.JPG

View solution in original post

9 REPLIES 9
Highlighted
Super User II
Super User II

Hi @sjbearbower ,

 

I would suggest you use the "Get file contents using a file path" output (File content) in the email "Attachments Content" and file name in "Attachments Name."

Here is an example:

filecon.png 

 

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Highlighted

Thanks so much for this suggestion.  However, in my case the # of files could be as few as 1 and as many as 3.  This is why I'm attempting to put the results in an array and then attach the array to the email.

 

If there's an easier way to accomplish this I'd love to learn it.  

 

Otherwise, if anyone has suggests on what I might be doing wrong with getting the results into an array or attaching the array that would be great as well.

Highlighted

Hi @sjbearbower ,

Here is sample flow that will allow to get files (one or more) from SharePoint Library and attach all to an email attachment:

 

MultiAttchment.png

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Highlighted

I've made it a little further.  I can use your example or my array example and I am now receiving an email with all attachments.  However, the attachment can't be opened or is viewed as corrupt.

 

Thoughts?  I'm using 

base64(body('Get_file_content_using_path_to_Question_folder_2')) as the function for the file ContentBytes.
 
 
Highlighted

Hi @sjbearbower 

 

You need to make sure the JSON structure is correct and had all the properties to make it work.

 

Could you please share a screen capture with expression, that would help to understand the issue.

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up. 

Highlighted

Here are some screenshots.  I have a text file of the full Json results that are being used to create the email but I can't attach them to this  response tool. Thanks  in advance for any advice.  Note: I've also tried base64(body('Filecontents') with the same results.  I know that FileContents does work because if I use this to attach as an individual file I get it.  So I must be missing something small in formatting of the JSON.

 

CodeCodefunctionfunctionresultsresults

 

 

 

 

Highlighted

Hi @sjbearbowe,
If your PowerAutomate works fine with single attachment but does not if you have more than one file, I would suggest you to check following:
When you have multiple files in attachment JSON make sure you are separate them with ,
Example;
[
{ ”filename”:<val>,”contentbytes”:<Val>},
{ ”filename”:<val>,”contentbytes”:<Val>},
{ ”filename”:<val>,”contentbytes”:<Val>}
]

Hope this help.
Highlighted

I finally figured out the magic.  Instead of attempting to only insert the file information I inserted the full File Content variable and then all worked wonderfully.

Here's my final screen shot for what worked in my append to array information.

 

append to array final.JPG

View solution in original post

Highlighted

Hi Gents, @sjbearbower , @DeepakS 

 

I can get the result of this step. 

DannyZheng_1-1599324135443.png

 

 

DannyZheng_0-1599323984573.png

However, I got an error when I put this array into attachment in an email. Do you have any idea?

DannyZheng_2-1599324170032.png

 

Thanks.

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (8,252)