How to Get Attachments from a SharePoint list item using Power Automate?

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
Get attachments from SharePoint list item using Power Automate

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.

Get attachments from SharePoint list item using Power Automate flow

Step:2

Add an Initialize variable action of type array, that we will use later in our flow.

Get attachments from SharePoint list item using 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
Get attachments from SharePoint list item using microsoft flow

Step:4

Select Apply to each action and pass the dynamic content values as an output from the previous steps:

power automate send email with multiple attachments from sharepoint list

Then select the Get Attachments action and provide the SharePoint site and List name, and also pass the dynamic content ID Value.

how to get attachments from sharepoint list in power automate
  • 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.
Get attachments from a SharePoint list item using Power Automate

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']}"
  }
}
get attachment content file identifier using Power Automate flow

Step:5

See also  How to call a javascript function when a checkbox is checked unchecked

To send an email, select the  Send an email (V2) action. And select the To address, Subject, and Body.

Get attachments from SharePoint list item using Power Automate example

Expand the Show Advanced option, switch the attachments mode to input the entire array then add the attachment array from the Dynamic content.

Get attachments from a SharePoint list item using Power Automate

Step:6

Save and Test the flow by selecting the Run flow option. Pass the EmployeeID and click the Run flow button.

Get attachments from a SharePoint list item using Power Automate

Here in the SharePoint list, we can see that the Selected list item contains 2 attachments in it.

get attachments from sharepoint list item in power automate flow

Once the flow ran successfully like below:

get attachments from sharepoint list item in power automate

We can see the mail has been received along with attachments presented for the requested EmployeeID list item.

Example to get attachments from sharepoint list item using the power automate flow

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:

>