Save email content to SharePoint
Microsoft Power Automate provides tools to help you build flows that monitor incoming emails and then save its metadata to Microsoft Lists and its attachment to a document library.
Save email attachments to a SharePoint document library
Microsoft Outlook has a trigger called When a new email arrives, which is used for this unit's example to monitor incoming emails and save the attachments to a SharePoint document library. The trigger is watching to determine if the email has attachments and if it was sent from a specific person with the words "Monthly Report" in the Subject field.
Prerequisites
- Access to create a SharePoint document library
- Access to Power Automate
Create SharePoint document library
From a SharePoint, select the Settings gear icon and then select Site contents.
Select + New and then select Document library.
Select Blank Library
In the name field, enter Incoming Emails and then select Create.
Select Add column and select Text. For the name type, select From Name.
Select Add column and select Text. For the name type, select From Email.
You now have a document library created.
Create the automated flow
From the Power Automate home page, select + Create on the left hand navigation menu, and then select Automated cloud flow.
Name the flow Incoming Emails.
Search for When a new email arrives(V3) in the Choose your flow's trigger field and select it.
Select Create.
In the top right hand corner, turn off the New Designer and select Switch without Saving when prompted.
Select the trigger and then select Show advanced options.
Add the options to help monitor the incoming emails closely and only capture the attachments from those who match your criteria. This example is monitoring the To, From, Include Attachments, and Subject Filter fields.
Select + New Step. Search for Sharepoint and then select Create file.
Select the Site Address and Folder Path for the Incoming Emails library.
Select the File Name field. The dynamic content box should open. If it doesn't, select Add dynamic content. From the dynamic content, select Attachments Name
Note
Power Automate automatically adds an Apply to each action outside of the Create File. This is to make sure that all attachments from the email are created in the SharePoint library.
Select the File Content field. Select Attachments Content from the dynamic content.
Beneath the Create file action, select Add an action again, search for SharePoint, and then select Update file properties.
In the Update file properties dialog box, select the Site Address and the Incoming Emails library.
Add the information from dynamic content shown in the following screenshot.
Select Flow checker to review for any errors and then select Save in the top right hand corner.
Run the flow
Your task is complete. Now, when Adele Vance receives an email from Miriam Graham and the email:
has at least one attachment
Subject field contains the words "Monthly Report"
Then the flow picks up the attachments and saves them in the Incoming Emails library.
The following screenshot shows what the SharePoint library looks like after an email was received.
Tip
When a file is uploaded to SharePoint, its file size is automatically identified and made available. The column name is called File Size and is hidden by default. You will need to add it to the view to display it.