Save email content to SharePoint

Completed

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

The Microsoft Outlook connector has a trigger called When a new email arrives, which is used for this unit's example to monitor incoming emails. When a new email arrives, the flow is triggered and saves 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 of the email.

Prerequisites

  • Access to create a SharePoint document library
  • Access to Power Automate

Create SharePoint document library

  1. From SharePoint, select the Settings gear icon and then select Site contents.

    Screenshot of a Sharepoint page and selecting the gear icon for settings and then selecting Site Contents.

  2. Select + New and then select Document library.

  3. Select Blank Library.

  4. In the name field, enter Incoming Emails and then select Create.

  5. Select Add column and select Text and select Next. For the name, type From Email and select Save.

    Screenshot of adding a column to a document library.

You now have a document library created with the necessary columns.

Create the automated flow

  1. From the Power Automate home page, select + Create on the left hand navigation menu, and then select Automated cloud flow.

  2. Name the flow Incoming Emails.

  3. Search for When a new email arrives(V3) in the Choose your flow's trigger field and select it.

  4. Select Create.

  5. Select the trigger and then select Show All from the Advanced parameters field.

    Screenshot of the When a new email arrives (V3) trigger with the Show advanced options command highlighted.

  6. Add the options to monitor the incoming emails and only capture the attachments from those who match your criteria. This example is monitoring the To, From, Include Attachments, and Subject Filter fields.

    Screenshot of the advanced options filled in.

  7. Underneath the When a new email arrives trigger, select the + icon and then Add an action.

  8. Search for Sharepoint, you might need to select See more and then select Create file. If you're prompted to sign in, make sure you select Sign in.

  9. Select the Site Address and Folder Path to the Incoming Emails library.

    Screenshot of the Create file dialog box with Folder Path selected and Incoming Email highlighted.

  10. Select the File Name field. Select the lightning bolt to open the Dynamic Content panel.

  11. Search for Attachments Name and select it.

    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.

  12. Select the File Content field. Select the lightning bolt to open the Dynamic Content panel.

  13. Search for and select Attachments Content from the dynamic content.

  14. Underneath the Create file action, select + then Add an action.

  15. Search for SharePoint, and then select the Update file properties action.

  16. In the Update file properties properties panel, select the Site Address and the Incoming Emails library.

  17. Select the Id field and then select the lightning bolt to open the Dynamic Content panel.

  18. Select the body/ItemId from the Create File action.

  19. Select Show All next to the Advanced parameters field.

  20. Select the Title field, then select the lightning bolt to open the Dynamic Content panel.

  21. Search for and select body/Name from the Dynamic Content panel.

  22. Select the From Email field, then select the lightning bolt to open the Dynamic Content panel.

  23. Search for and select From from the Dynamic Content panel.

    Screenshot of the Update file properties dialog box.

  24. Select Flow checker to review for any errors and then select Save in the top right hand corner. The entire flow should look like this screenshot.

    Screenshot of the completed flow properties.

Run the flow

Your task is complete. Now, when Miriam Graham receives an email from Adele Vance 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.

Screenshot of the SharePoint library for Incoming Email.

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.