Power Automate : Extract multiple attachments from list item and send as mail attachments

Introduction

One of the common requirements while working with Power Automate is the need to send multiple attachments along with the mail. In this article we will see how to kickstart a flow on item creation that has multiple attachments and we will see how to extract and send them in a mail.

Use Case

One of the use case could be in a help desk system where the user creates the ticket as an item with multiple screenshots which has to be send to the issue resolver as a mail with attachments.

Create the Flow

So as to implement the scenario lets go ahead to Power Automate and create a flow with the trigger “When an Item is created”

We will then add the steps to extract the attachments from the newly added list item. We will make use of the Get Attachments action

Now we will initialize an array to hold all the attachment that is present as an output to the above action.

Once the array is initialized we will use a for loop to iterate through the body of the Get Attachments action and append it to the array variable as shown below:

Here the Body is the the Output of the Get Attachments Action. Once its selected, add the Get Attachment Content Action and specify the ID as :

  • Id : Select the ID field rom the When an item is created Dynamic Content section
  • File Identifier: Select the Id from the Get Attachments Dynamic Content section

Now lets see how to append the content to the array variable.

Append to Array Variable Value body has two properties – Name and ContentBytes. We will be assigning the DisplayName, retrieved from “Get Attachments” action to the Name property and the Attachment Content, retrieved from “Get Attachment Contents” action to the ContentBytes property. However the attachment content has to converted to base 64 for which we can go to  Dynamic Content, click on Expressions , enter base64(), and finally go back to Dynamic Content and add "Attachment Content". The expression looks like the one below :

base64(body('Get_attachment_content'))

As the final step, lets add the Send email action and specify the Array variable in the attachment field

Test the implementation

Now lets test the flow by creating an item with multiple attachments in the SharePoint List and see if we will receive the mail with the list item attachments.

Heading over to Power Automate, we can see that the flow has run successfully.

Heading over to gmail we can see the email with multiple attachments

Summary

Thus we saw how we can extract the multiple attachments from a list item and send it as an email attachment