In this post I’ll show you how to read a SharePoint List item along with its attachments, and then email those attachments using the Send Mail action in Power Automate.
What does the flow do?
The flow uses a manual trigger and requests the user to enter a SharePoint List item ID. The file attachments associated with the item ID are then emailed to the user.
The demo SharePoint List I’m using is called Contracts Library as shown below. The list item ID that the user wants to enter when running the flow will be 47.
List item 47 has three file attachments:
When the flow is run the user is requested to enter a List item ID, for example 47:
The flow executes and an email containing three file attachments is sent to the user:
Finally, open each file attachment to ensure that the files are not corrupt and are valid documents:
Here is the flow that we will build
Building the flow
1. For this demo we’ll start by creating an Instant cloud flow:
2. The flow will use a manual trigger. Give your flow a name then select the trigger as Manually trigger a flow (1):
3. We want to request that the user enters a SharePoint List item ID number when the flow is run. Open the Manually trigger a flow action and click Add an Input:
Next, change the name of the number field. You can also update the help text to something more meaningful:
4. Add a Get attachments action (2). Select the SharePoint site and List. For the Id select List Item ID from Dynamic content:
5. Add an Initialize variable action (3) of type array:
We will store the content of each attachment in the array variable varAttachmentOutlook.
6. Add an Apply to each loop (4) and set the Get attachments Body (5) as the output from previous step as shown below:
The Apply to each loop will get the content of each attachment and store the attachment content and attachment name in the array variable varAttachmentOutlook.
7. Add a Get attachment content (6) action:
8. For the Id select the List Item ID, and for the File Identifier select the Id (File Identifier) from Get attachments:
9. Next add an Append to Array variable (7) action:
The array variable will store the attachment name (Display Name) and attachment content in a JSON object. Enter the following as shown in the steps below:
Pay attention to the brackets, quotation, colon and comma characters:
Select the Attachment Content and Display Name from dynamic content as shown below:
10. The final action is the send mail action. Add a Send an email (V2) action (8):
11. Select Show advanced options:
12. Next switch the attachments mode to input entire array, then add the attachment array from Dynamic content as shown below: