Send an email with multiple (0 – n) item attachments in Power Automate

“I need to send all item attachments in a single email, but Power Automate flow is sending multiple emails, each with a single attachment.”

‘Get attachments’ action in Power Automate returns all attachments for given item in an array. The ‘array’ part is important. Every time you use data stored in an array, Power Automate will add automatically ‘Apply to each’ action around it. That means, once you try to add the attachment into an email, it’ll add ‘Apply to each’ around the ‘Send an email’ action. The result: one email per attachment.

Power automate sending one email per attachment

To send only one email, the ‘Send an email’ action must be outside of the ‘Apply to each’. And to achieve that, you can’t use the output from ‘Get attachments’ directly, you need a variable. A single array variable that will contain all attachments.

Adding the attachments

First step is to initialize the array variable.

Power Automate Initialize variable

The next step is to process the attachments. First you get all of them using ‘Get attachments’, then you ‘Get attachment content’ for each of them. These two actions give you all you need for the array variable. You build the variable using ‘Append to array variable’ action with the following code.

  "Name": <DisplayName>,
  "ContentBytes": <AttachmentContent>

Warning: make sure you don’t add any character nor white space after the <AttachmentContent> dynamic content. Otherwise you’ll end with ‘AttachmentContentNotValidBase64String’ error.

The last step is to send the email…

Power Automate send multiple attachments in an email

…with the variable as the attachments array.

Power Automate add array variable to email attachments


The most important part of this post is to get an idea how arrays work. When you get action output in form of an array, Power Automate will process its content one by one. It’ll add the ‘Apply to each’ action and repeat all the actions inside for each item in the array. If you keep ‘Send an email’ action inside ‘Apply to each’, it’ll repeat the action.

You can’t avoid the ‘Apply to each’ action when processing multiple attachments. But you can use it to convert the array into different format. And then use the variable instead of the original dynamic content. The principle is the same, no matter if it’s multiple attachments in an email or multiple attachments in a task.

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.


Add a Comment

Your email address will not be published. Required fields are marked *