🖇️How to read SharePoint List item attachments and send them via email using Power Automate

In this article, I will walk you through the process of reading a SharePoint List item and its associated attachments, followed by the step-by-step instructions on how to email those attachments using the Send Mail action in Power Automate. By the end of this post, you will have gained the knowledge and skills necessary to effectively read SharePoint List items and send their attachments via email using 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.

This is the demo SharePoint List . This is the item ID that the user will enter is 47 when running the flow.
This is the demo SharePoint List. The item ID that the user wants to enter when the flow runs will be 47.

List item 47 has three file attachments:

The item has three file attachments.
The item has three file attachments:

When the flow is run the user is requested to enter a List item ID, for example 47:

When the flow is run the user is requested to enter a List item ID, for example 47
When the flow is run the user is requested to enter a List item ID.

The flow executes and an email containing three file attachments is sent to the user:

An email containing the three file attachments has received.
An email containing the three file attachments has been received.

Finally, open each file attachment to ensure that the files are not corrupt and are valid documents:

Open each file attachment to ensure that the files are not corrupt and are valid documents.
Open each file attachment to ensure that the files are not corrupt and are valid documents

Here is the flow that we will build

Image of the flow we will build
This is the flow that we will build

How to Display the ID column

1. Click the Add Column option, then select Show or Hide Columns:

2. Tick the ID column then click Apply. Use the arrows ∧ ∨ to change the ordering of the columns:

Tick the ID column then click Apply.

Building the flow

1. For this demo we’ll start by creating an Instant cloud flow:

Select Instant Cloud Flow
Select 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):

Select Manually trigger a flow
Select Manually trigger a flow
The flow is triggered with a manual trigger action
The flow is triggered with a manual trigger action

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:

Select Add an input to the Manual trigger.
Select Add an input

Click Number:

We want to request that the user enters a SharePoint List Item ID number when the flow is run. Select Number for the manual trigger.
Select Number.
A number input has been added to the  manual trigger.
A number input has been added to the manual trigger.

Next, change the name of the number field. You can also update the help text to something more meaningful:

Change the name of the number field to List Item ID.
Adding a number input to the manual trigger.
Changing the name of the number field and updating the help text to something more meaningful.
Changing the name of the number field and updating 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:

Adding the Get attachments action (2). Select the SharePoint site and List. For the Id select List Item ID from Dynamic content.
Get attachments action
For the Get Attachments Id select List Item ID from Dynamic content
For the Id select List Item ID from Dynamic content

5. Add an Initialize variable action (3) of type array:

Initialize variable action for the attachments array
Initialize variable action for the attachments 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:

Add an Apply to each loop (4) and set the Get attachments Body (5) as the output from previous step as shown below
Add an Apply to each loop (4) and set the Get attachments Body (5)

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:

Add a Get attachment content (6) action
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:

For the Id select the List Item ID, and for the File Identifier select the Id (File Identifier) from Get attachments
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:

Add an Append to Array variable
Add an Append to Array variable

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:

Add an append to array action. The array variable will store the attachment name (Display Name) and attachment content in a JSON object.
The array variable will store the attachment name (Display Name) and attachment content in a JSON object.

Pay attention to the brackets, quotation, colon and comma characters:

The array variable will store the attachment name (Display Name) and attachment content in a JSON object. Pay attention to the brackets, quotation, colon and comma characters in the JSON code.
Pay attention to the brackets, quotation, colon and comma characters:

Select the Attachment Content and Display Name from dynamic content as shown below:

Select the Attachment Content and Display Name from dynamic content
Select the Attachment Content and Display Name from dynamic content

10. The final action is the send mail action. Add a Send an email (V2) action (8):

Add a Send an email (V2) action
Add a Send an email (V2) action

11. Select Show advanced options:

In the Send an email (V2) action 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:

Send an email action containing the attachment array.
Switch the attachments mode to input entire array, then add the attachment array from Dynamic content

Trouble shooting

If you find that attachments do not open, see Short Notes: The format of File Attachment Arrays for Approvals and Outlook Emails


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: