Do you want to save email attachments to SharePoint using Power Automate Automate? This Power Automate tutorial will show us how to save email attachments to SharePoint in Power Automate.
Also, we will cover how to save email attachments to SharePoint with a different name using Power Automate. Finally, we will save only PDF attachments to SharePoint using Power Automate.
Power Automate save email attachment to SharePoint
Here we will see how to save email attachments to the SharePoint document library using Power Automate.
For example, we receive ‘Resume attachments’ in the company Outlook email address every day, and I want to automatically save those attachments to the Resume document library in SharePoint.
To do this in Power Automate I have followed the below steps:
1. Open Power Automate Cloud, create an Automated Cloud flow, and then select a trigger action as ‘When a new email arrives (V3)’ action. Then provide the below information:
- Folder: Select Inbox from the option
- Include Attachments: Select the Yes option
- Only with Attachments: Select the Yes option.
2. Now we will get email attachments, for this, click on the +New step -> select Get attachments(V2) action. Then provide the below information:
- Message Id: Select Message ID from dynamic content. This will automatically apply to each action.
- Attachment id: Select Attachment attachment id from dynamic content.
3. Finally, we will save email attachments in the SharePoint document library, for this click on the +New step -> select Create file action. Then provide the below information:
- Site address: Provide the SharePoint site address.
- Folder path: Select the Folder path from dynamic content.
- File name: Select the file name from dynamic content.
- File content: Select the content bytes from dynamic content.
4. Now save the flow and run the flow manually, then send an email to the Outlook inbox.
You can see the above email attachments are saved in the SharePoint document library
This is how to get attachments from email and save to the SharePoint document library using Power Automate.
Power Automate save email attachments to SharePoint with a different name
Here we will see how to save email attachments to SharePoint with a different name using Power Automate.
For example, whenever a client sends project-related documents via email, I want to automatically save these attachments to the SharePoint document library named “Project Documents” with a new name that includes the original attachment name and today’s date.
To save email attachments to SharePoint with a different name follow the below steps using Power Automate.
1. Open Power Automate Cloud, create an Automated Cloud flow and then select a trigger action as ‘When a new email arrives (V3)’ action. Then provide the below information:
- Folder: Select Inbox from the option
- Include Attachments: Select the Yes option.
- Only with Attachments: Select the Yes option.
2. Next, initialize two variables for the Attachment name and today’s date. for this click on the +New step -> select Initialize variable. Then provide the below information:
Name | Type | value |
---|---|---|
Attachment name | String | |
Todays date | String | formatDateTime(utcNow(),’yyyy-MM-dd’) |
3. To get the attachment from an email, click on the +New step -> select Get attachment(V2) action. Then provide the below information:
- Message-Id: Select Message ID from dynamic content. This will automatically apply to each action which will loop through messages.
- Attachment id: Select Attachment attachment id from dynamic content. this will add another Apply to each action that will loop through attachments.
4. To get the attachment or file name, for this, click on the +New step -> select Compose action. Provide the below information:
- Inputs: Provide the below expression:
first(split(outputs('Get_Attachment_(V2)')?['body/name'], '.'))
5. To get the attachment extension, click on the +New step -> select Compose action -> provide the below information:
- Inputs: Provide the below expression:
last(split(outputs('Get_Attachment_(V2)')?['body/name'], '.'))
6. Next, we will combine filename, today’s date, and extension to create a new file name, for this click on the +New step -> select Set variable action. Then provide the below information:
- Name: Select the Attachment name from the dropdown.
- Value: Provide the below expression:
concat(outputs('Compose'), '-', variables('Date'), '.', outputs('Compose_1'))
7. To save email attachments to SharePoint with different names, click on the +New step -> select Create file action, and then provide the below information:
- Site address: Provide the SharePoint site address
- Folder path: Provide the folder path
- File name: Select the Attachment name variable from dynamic content.
- File content: Select content bytes from dynamic content.
8. Now save the flow and run the flow manually. Then send an email to the Outlook inbox.
You can flow runs successfully and the email attachment is saved to SharePoint with a different name.
This is how to save email attachments to SharePoint with different names using Power Automate.
Power Automate saves only PDF attachments
Here we will see how to save only PDF attachments to the SharePoint document library using Power Automate.
when an employee submits an expense reimbursement document via email, requesting reimbursement, the attachments will be automatically saved in the Expense Reimbursement Document Library in SharePoint.Additionally, a condition is applied to ensure that the document is in PDF format.
To do this using Power Automate follow the below steps:
1. Open Power Automate Cloud, create an Automated Cloud flow, and then select a trigger action as ‘When a new email arrives (V3)’ action. Then provide the below information:
- Folder: Select Inbox from the option
- Include Attachments: Select the Yes option.
- Only with Attachments: Select the Yes option.
2. Next, we will check the attachment type, for this click on the +New step -> select Condition action. Provide the below information:
- Choose a value: Select the Attachment name from dynamic content. This will Apply to each action to the flow.
- Operator: Select the operator as ‘contains’ from the option
- Choose a value: Write the value as .pdf
3. If the condition is true, then we will get an attachment from the email, for this, click on the +New step -> select Get attachment (v2) action.
Provide the below information
- Message Id: Select Message ID from dynamic content.
- Attachment id: Select Attachment attachment id from dynamic content. This will add another Apply to each action that will loop through attachments.
4. To save only PDF attachments in the SharePoint document library, for this, click on the +New steps -> select Create file action. Provide the below information:
- Site address: Provide the SharePoint site address
- Folder path: Provide the folder path
- File name: Select the Attachment name variable from dynamic content.
- File content: Select content bytes from dynamic content.
5. Now save the flow and run the flow manually. Then send an email to the Outlook inbox to trigger the flow.
You can flow runs successfully and the email attachment is saved to SharePoint with a different name.
This is how to save only PDF attachments to the SharePoint library using Power Automate.
Conclusion
In this Power Automate tutorial, I have explained how to save email attachments to SharePoint using Power Automate. This tutorial will help you to get attachments from email and save to the sharepoint document library using Power Automate. Also, it covers:
- Power Automate save email attachments to SharePoint with a different name
- Save email attachment to SharePoint in Power Automate.
- Power Automate save only PDF attachments
You may also like:
- Copy List Items To Another List In SharePoint Using Power Automate
- When a New Email Arrives Subject Filter in Power Automate
- Power Automate delete all files in SharePoint folder
- Power Automate Get items
- Auto Populate SharePoint List Columns Based on Value in One Column using Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Hi sir
Is there a way to upload pdf documents from local to multiple share point lists based on ID
Thank you Bijay! I have a question – we have an email called accounting to which all our vendors send thier invoices to. I need all attachments that are sent to that email to be saved to Sharepoint. So instead of from email address do I use to email address?
I cannot wrap my head around this particular flow. Why does it need IsFromFilterApplied condition? Cannot I just specify “from” e-mail address in trigger if I want this flow to save attachments from mails from particular person? What’s the difference?
Hi Bijay,
Thank you for these lessons..really appreciated it.
I have tried one of the flows to save and rename the file in the share point whenever a new email attachment comes to the inbox. But unfortunately, I am getting the error, It’s creating duplicate files, actual files and files with date …. How to resolve this?
I got the answer, Kindly delete the bove comment .
Hi Bijay.
Great tutorial. I am new to powerflow. I want to get mail attachment(s) of type excel table and extract data to share point list. Is it even possible achieve in one or two flows.
Best regards.
Hello,
Can you confirm me is there a way to upload images directly from FTP server to a sharepoint online library/folder.
What s the Field Name of Status Code in the Iteration
We have created a flow to download email attachments on every email arrival. Do we need to schedule or Automate this flow ?
Hello Bijay Kumar !!! How are you? See if you can help me. I receive emails from some suppliers that send XML files as an attachment within an attachment. As if they were forwarding the message. I currently use powershell to download and script to extract the XML from within the messages (Extension .msg). I just need to download these MSG-type attachments. I even created a flow, but the messages get smaller. For example, a 106KB file becomes 60KB in size