Premise
In this post, we’ll discuss how we can automate certain operations around SharePoint List attachments using Microsoft Power Automate. We’ll be discussing the following items: –
Solution
Copy attachments to a document library
Here, the idea is to copy the attachments to a separate document library.
This might be important if, there’s a case scenario of attaching multiple files as attachments. A document library is much more versatile in dealing with files than just plain attachments.
Here’s what we’re going to do. For each list item, we’ll create a new folder in a document library and add all the attachments there.
- Set the trigger for, When an item is created.
- Create new Folder. Folder name is a combination of item title and item id so as to generate a unique name. Folder path is set to, concat(triggerBody()?[‘Title’], ‘_’, triggerBody()?[‘ID’])

- Get all the attachments

- For each attachment, download the file content. Input for “Apply to each” is the “Body” from the previous step. ID is the item ID in question. File Identifier is the current attachment’s id.

- Create a new file in our destination library.

The input can be defined as below,
Property | Action From | Formula |
---|---|---|
Folder Path | Create New Folder | body(‘Create_new_folder’)?[‘{FullPath}’] |
File Name | Current Attachment Name | items(‘Apply_to_each’)?[‘DisplayName’] |
File Content | Current Attachment File content | body(‘Get_attachment_content’) |

Send list attachments as Email attachment
- I’m keeping the trigger same as, when a new item is created. But, set it as per your requirement.
- Initialize an empty array variable. This will be used to temporary store all the attachments files.

- Next, get all the attachments for the current item

- For each attachment, download the file content. Input for “Apply to each” is the “Body” from the previous step.

- Store the file content in our array variable in the following format. Name is the DisplayName from the previous step. ContentBytes is also from the previous step

- Finally, send the email with the following parameters.


Delete attachment
There’s an OOTB Flow action card to delete an attachment easily.

Key Takeaways
- Attachment is a key component of a SharePoint list.
- In this post I’ve demonstrated, some of the key operations that can be done around SharePoint attachments.
- Using SharePoint files as attachment, we need to ensure the JSON format is in correct format.
Icon made by Pixel perfect from www.flaticon.com
This is exactly what I needed, a short clear guide to using sharepoint item attachements in Power Automate. Thanks Piyush
LikeLike
Thanks for the blog, it really helped to achieve the exact need.
LikeLike
Thank you for this solution!
Is there a way to copy a file from a document library and attach it to a SharePoint list item as an attachment? – Thanks!
LikeLike
Hi, I tried your flow and it works fine for every attachment, excepting .msg files, which are saved emails and attached to a SharePoint list. Is it happening just to me or you also?
Thanks!
LikeLike
Hi there, i managed to get it to work, but my flow is now being repeated per attachment
LikeLike