Power Automate: Handling Multiple Attachments

From time to time you may want to handle multiple attachments in Power Automate, this could be to:

  • Attach them to an email
  • Attach them to a workflow approval

One way of doing this is to create an array holding the details for the attachments, then adding the array to the attachments property of the action.

Part 1 – Initialising the Attachment Array

To initialise the attachment array add the “Initialise Variable” action and provide it with a Name and select the Type as an Array.

You can leave the Initial Value empty for now.

Part 2 – Getting the attachments

Depending on where you are retrieving the files from, whether it be a SharePoint list item, Document Library or attachments submitted through a Microsoft Form, will depend on how you retrieve the content.

In this example I am using the attachments uploaded through a Microsoft Form. If you need help on getting attachments through a Microsoft Form, check out my previous articles and video on Microsoft Forms.

I am using the “Get file content using path” for SharePoint to retrieve the content and using the “Append to array variable” action and add an object which includes the:

  • Name of the file
  • ContentBytes – which is the content returned from the “Get file content using path” action

This object is required for each attachment and once appended to the attachments array we can use it to either send an email or attach the files to an approval

Part 3 – Using the attachments

Once you have the array of attachments you can pass it to an action. In this case I’m going to send them via email

To send an email you can add the “Send an Email” for Outlook action. By default you won’t be able to see the attachment section however if you select the “Show Advanced Options”.

Once you can see all the options you can fill in:

  • Who the email needs to be sent to
  • Subject of the email
  • Body of the email

If you were only going to send one attachment you would enter the name of the file and the content for the file in the Attachments section. However since we are going to add multiple attachments that are stored in the attachment array we need to click on the “Switch to input entire array” button

This will change the view of the Attachments section and allow you to input the attachment array variable

Wrap Up

That’s it, you can now save and test the flow

Below are screenshots for the entire flow, including picking up the attachments from a submitted form.

About: Gareth

Leave a Reply

Your email address will not be published.