cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
maxtarneberg Advocate II
Advocate II

Add more than one array as an email attachment

Hi all,

 

Is it possible to add an array and output as content for an email attachment?

 

I am trying to create a flow which has two branches, resulting in an email at the end. 

On one branch I have a loop that gathers a series of photos from a doc library, and put the photos in an array

On the other branch I have a csv table built on items from a SP List

 

How can I bring these together as attachments, one being an array and one being output from create file/get file content?

The create email outlook 365 (V2) allows only to use an array or attachment name/content

Or can I add my csv file to the array?

 

Any help appreciated

 

Thanks

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Add more than one array as an email attachment

Hi @maxtarneberg 

 

Thanks for your reply.

 

Merging two arrays with two different content going to be tricky.

 

The below link explains how to merge two arrays. Not sure this is useful for your case or not.

https://powerusers.microsoft.com/t5/Building-Flows/Merging-arrays/td-p/386279

 

Getting large libraries please see below.

https://veenstra.me.uk/2018/05/23/microsoft-flow-querying-large-libraries/

 

The below link might be useful for attaching multiple contents in a single email

https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

8 REPLIES 8
Super User
Super User

Re: Add more than one array as an email attachment

Hi @maxtarneberg 

 

Try the following

image.png

 

Above Append value is as follows:

 

{
"Name": "test.csv",
"ContentBytes": "@{body('Create_HTML_table')}"
}

 

Next for the SharePoint how to append the files please have a look at my blog

https://mydevexperience.wordpress.com/2019/10/12/microsoft-flow-retrieve-all-files-from-sharepoint-l...

 

Finally you will have one append array which you can user for sending as one email with all the attachments.

 

The key is declare the array variable as a global variable where you can use is any branch of the flow.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
maxtarneberg Advocate II
Advocate II

Re: Add more than one array as an email attachment

Hi @abm,

 

Thank you for your suggestion. 

 

Unfortunately my flow is failing at the email stage due to bad request.

 

Perhaps you could look at my flow and see where this might be going wrong?

 

Thank again

 

Untitled7.pngUntitled8.png

Super User
Super User

Re: Add more than one array as an email attachment

Hi @maxtarneberg 

 

Could you test your logic only with one branch and see that works or not? Then try with other branch. Later combine both. This way you will know which branch is having issues. Let me know how it goes.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
maxtarneberg Advocate II
Advocate II

Re: Add more than one array as an email attachment

Hi @abm,

 

Thank you for your suggestion, I have done some testing.

 

I have created a duplicate flow of the 'getting pictures' branch and that works to some extent, but doesn't get all of the pictures which meet the filter query, just some of them. I know they meet the filter query because they all have a common GUID string within the filename. But within the complete flow, as a branch, it doesn't return any attachments. I'm not sure why.

 

The HTML table branch doesn't work at all. If I use the code you provided for ContentBytes, it says "the expression is invalid", (I have been careful to type it out to avoid apostrophe issues). But your code looks valid to me.

Alternatively if I select the Output from the Create HTML table stage, it says bad request.

 

Is it worth trying to rebuild the flow? I have my suspicions about the stability of MS Power Automate, it seems quite fragile to change.

Do you think it is possible to create an email with a spreadsheet or table and pictures can be attached, where GUIDs are available to relate from the selected item.

 

Thank you for your support

Max

 

Super User
Super User

Re: Add more than one array as an email attachment

Hi @maxtarneberg 

 

Thanks for the reply.

Not sure your append array is creating issues here as it is under a branch.  Could you use two different array to append each branch? Then merge into one. 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
maxtarneberg Advocate II
Advocate II

Re: Add more than one array as an email attachment

Hi @abm,

Thank you for your continued support

 

I have settled on a solution where I embed the data into the email body as an HTML table and add only photos to the attachment array. This is producing quite a nice result, and a valuable report for our needs. See below.

 

I feel that merging the photo array with another array that contains a *.csv file would still be desirable on top of this.

Any advice on how to merge attachment arrays into one single attachment array?

 

One of the issues was that not all of the photos that matched the filter query were being added to the attachment array.

The solution to this was to put the top count at 5000 in the Get Files (porperties only) action.

It turns out that 'default = all', is just not 'all' at all, as you might expect.

 

Untitled.png

Super User
Super User

Re: Add more than one array as an email attachment

Hi @maxtarneberg 

 

Thanks for your reply.

 

Merging two arrays with two different content going to be tricky.

 

The below link explains how to merge two arrays. Not sure this is useful for your case or not.

https://powerusers.microsoft.com/t5/Building-Flows/Merging-arrays/td-p/386279

 

Getting large libraries please see below.

https://veenstra.me.uk/2018/05/23/microsoft-flow-querying-large-libraries/

 

The below link might be useful for attaching multiple contents in a single email

https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

maxtarneberg Advocate II
Advocate II

Re: Add more than one array as an email attachment

Hi @abm 

 

Thank you for your help, it is much appreciated

 

Those are very useful resources

 

Max

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,437)