In this Power Automate tutorial, we will learn how to get attachments from a SharePoint list item using Power Automate. And also we will cover how to email those attachments using the Send Mail action in Power Automate.
Scenario:
The flow uses a manual trigger and requests the user to enter a SharePoint List EmpID. The file attachments associated with the requested Emp ID are emailed to the requested user.
Here I’m going to use the below Employee list:
- EmployeeID – Default title column
- EmployeeName – Text column
- EmployeeStatus – Choice column
- Attachments – Attachments column
Follow the below steps, to build a flow to get attachments from the SharePoint list item.
Get attachments from a SharePoint list item using Power Automate
Let us see how to get attachments from a SharePoint list item using Power Automate.
Step:1
Create an instant cloud flow that triggers manually. Expand the Trigger and add a text input for an EmployeeID.
Step:2
Add an Initialize variable action of type array, that we will use later in our flow.
Step:3
- Select the Get items action and configure the SharePoint site address and the list name.
- In the Filter Query, pass the EmployeeID to get an attachment for the selected employee list item.
"Title eq '@{triggerBody()['text']}'"
where,
- Title – Column internal name
- eq – Operator
- triggerBody()[‘text’] – dynamic content value
Step:4
Select Apply to each action and pass the dynamic content values as an output from the previous steps:
Then select the Get Attachments action and provide the SharePoint site and List name, and also pass the dynamic content ID Value.
- Add a Get attachment content action and configure the SharePoint site address, SharePoint list name, and list id.
- In the File identifier, pass the dynamic content to get the attachments file identifier id. It will automatically add apply to each action and loop through.
Now select an Append to array variable action and choose the initialized variable. In the value section pass the below expression.
{
"name": "@{items('Apply_to_each')?['DisplayName']}",
"contentBytes": {
"$content-type": "@{body('Get_attachment_content')?['$content-type']}",
"$content": "@{body('Get_attachment_content')?['$content']}"
}
}
Step:5
To send an email, select the Send an email (V2) action. And select the To address, Subject, and Body.
Expand the Show Advanced option, switch the attachments mode to input the entire array then add the attachment array from the Dynamic content.
Step:6
Save and Test the flow by selecting the Run flow option. Pass the EmployeeID and click the Run flow button.
Here in the SharePoint list, we can see that the Selected list item contains 2 attachments in it.
Once the flow ran successfully like below:
We can see the mail has been received along with attachments presented for the requested EmployeeID list item.
This is how to get attachments from a SharePoint list item using Power Automate flow.
Conclusion
In this Power Automate tutorial, we have learned how to get attachments from a SharePoint list item using Power Automate or Microsoft Flow. And also we covered how to email those attachments using the Send Mail action in Power Automate.
You may also like:
- Power Automate Filter Query Operators
- Power Automate Condition If Blank
- Power Automate Dataverse Update Multiple Rows
- Power Automate Create Document Library
- Create an Array from SharePoint list Items using Power Automate
- How to attach files to planner tasks using Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.