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.
One of the use cases could be in a help desk system where the user creates the ticket as an item with multiple screenshots which must be sent to the issue resolver as a mail with attachments.
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 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 from the When an item is created Dynamic Content section
- File Identifier: Select the Id from the Get Attachments Dynamic Content section
Now let’s 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 be 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 :
As the final step, let’s add the Send email action and specify the Array variable in the attachment field
Now let’s 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
Thus, we saw how we can extract multiple attachments from a list item and send it as an email attachment