cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sjbearbower
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

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
DeepakS
Resident Rockstar
Resident Rockstar

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.

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.

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.

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.
 
 

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. 

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

 

 

 

 

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.

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

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,871)