Share Multiple Attachments of SharePoint List via Email using Power Automate
I have written an article here on how to share multiple attachments via Email using Power Automate.
Let us have a look at a detailed steps to implement this .
Step 1 – Create the blank Microsoft Flow
- Go to flow.microsoft.com, sign in with your work or school account, click on My flows menu in the left navigation bar, and then click on ‘+New’ and Select Instant – from blank.
- Click on the Skip option given below and then give the flow name at top left in next screen.
Step 2 – Select a Trigger point of the Flow
- Search for the appropriate trigger when you want the flow to initiate.
- Here, we will select the trigger as ‘When an item is created’ which means that the flow will run whenever a new item is created in selected SharePoint list.
- Select the Site Address and List name where an item will be added along with the attachments.
Step 3 – Initialize Variable and Get List Attachments
- Click on +New Step and Choose an action ‘Initialize Variable’.
- Give the variable name say ‘AttachmentArray’ of type Array which we will use to create an array of all the attachments of newly created item.
- Now, add another action ‘Get attachments’ and select the Site Address and List name .
- Set the Id to ID of When an item is created trigger from the Dynamic content which appears in right as shown below.
Step 4 – Read Attachments Content and Create an Array
- Add an action ‘Get attachment content’ and select the Site Address and List name .
- Set the Id to ID of When an item is created trigger from the Dynamic content which appears in right.
- Set File Identifier to Id of Get attachments from the Dynamic content as shown below.
- As soon as you set the File Identifier , an Apply to each loop will be added automatically in order to get the attachment content of each file.
- Add ‘Append to array variable’ action after Get attachment action and within the Apply to each loop.
- Select the variable ‘AttachmentArray’ as Name which we have created at the beginning of the flow.
- Set the Value to the following JSON where
Name – will be the DisplayName of Get attachments
ContentBytes – will be the Attachment content of Get attachment content.
{ "Name": @{items('Apply_to_each')?['DisplayName']}, "ContentBytes": @{body('Get_attachment_content')?['body']} }
Step 5 – Send attachments via Email
- Finally, add an action ‘Send an email (V2)’.
- Set the values of To, CC and BCC to whom you have to send an email and add Subject, Body .
- Set the From(Send as) value to the Email address to send mail from if needed else the mail will be sent from the person whose connection is set in the flow.
- Set the value of Attachments to AttachmentArray variable.
- Set the Importance to Low, Normal or High if needed.
That’s all, the flow is ready in few simple steps.
Now, let us check how the flow will work .
Add a new item in the SharePoint list along with the multiple attachments .
I have created an item and added 2 attachments with it .
An Email is received having the attachments as shown below –
Comments
-
Share Multiple Attachments of SharePoint List via Email using Power Automate
To make the email action work outside the apply to each using the variable array you have to click the small square button next to 'Attachments' in the mail action. Then it switches so you can input the array variable.
-
Share Multiple Attachments of SharePoint List via Email using Power Automate
This article originated a while ago but does address my question, so I'm hoping someone sees this and can help.
I've created a flow in power automate that is supposed to send an email with attachments whenever a new item is added to the list using power apps.
My flow fails at this point:
And the error details:
I have tested this flow many times. Everything works except when I try to set up for attachments.
Any help or hints would be greatly appreciated.
TYIA
-
Share Multiple Attachments of SharePoint List via Email using Power Automate
The AttachmentsArray does not appear as an option for me in the dynamic content for sending an email - please help!
-
Share Multiple Attachments of SharePoint List via Email using Power Automate
Hello,
I am doing the exact same thing but my flow does not work
The Send an Email V2 part has this error
Can you help me to solve this?
-
Share Multiple Attachments of SharePoint List via Email using Power Automate
Thank you for clean layout! @Diksha
I am able to do this successfully with a Send an Email (V2) connector. However, I get an error with the same array variable using the Create an approval connector.
Error Details:
The request content was invalid and could not be deserialized: 'Could not find member 'ContentBytes' on object of type 'ApprovalsConnectorAttachment'. Path 'attachments[0].ContentBytes', line 1, position 333.'.
Output Error Details:
"code": "InvalidRequestContent","message": "The request content was invalid and could not be deserialized: 'Could not find member 'ContentBytes' on object of type 'ApprovalsConnectorAttachment'. Path 'attachments[0].ContentBytes', line 1, position 333.'." -
Share Multiple Attachments of SharePoint List via Email using Power Automate
Hi @Diksha interesting article just wondering how I would add attachments from a Microsoft form submission to an approval email? Or am I best building 2 flows one to add the data to a list and then another to email off the attachments in an approval flow?
Many Thanks
*This post is locked for comments