How To Copy Email Attachments To SharePoint Document Library Using Microsoft Flows

In this article, we will see how we can utilize Microsoft Flows to copy email attachments from Outlook Emails to SharePoint Document Library.

In this article, we will see how we can utilize Microsoft Flows to copy email attachments from Outlook Emails to SharePoint Document Library.

To continue with this demo we can start by adding a document library to a SharePoint site, let’s call it “Outlook Attachments”.

SharePoint

Now, go to Microsoft Flow designer and start with adding a workflow.

As I explained in my earlier articles we need to start with selecting a trigger for this workflow.

Since we need to copy the email attachments to the document library, we have two Cloud Services “Office 365 Outlook” and “SharePoint Online” to deal with.

Select “Office 365 Outlook” as connector and “Office 365 Outlook – When a new email arrives” as a trigger to kick off this workflow.

SharePoint

Choose the Outlook folder or subfolder that you want to monitor. Here I am selecting “Inbox” as target folder. This means workflow will trigger only if the email arrives in Inbox folder and rest of the emails will be ignored.

SharePoint

Set “Has Attachment” = Yes, this setting will further filter out the incoming emails based on if they have attachments or not.

We are only monitoring emails with attachments and that’s what these filters will achieve for us.

Set “Include Attachments” = Yes, this is required so that Workflow runtime includes the binary information of each of the attachments and makes it available to be written to SharePoint Library.

SharePoint

Add another action with “SharePoint” as a connector.

Select “SharePoint – Create a file” as a trigger, this action will be responsible to write down the attachment binaries to SharePoint Library.

SharePoint

Enter Site URL where we have “Outlook Attachments” document library sitting.

Select document library name from the lookup in the Folder Path Field.

SharePoint

Select “Name” property in the File Name field, this property represents the name of the attachment.

SharePoint

Select “Content” in the File Content Field, this property will hold the binary data for the attachment being written to the SharePoint Document Libraries.

Here it is important to note that if we do not set the “Include Attachments” = Yes, then the Content property will be null and will cause not write operations to takes place.

SharePoint

Add another action to the workflow, which will be responsible to send an email after the attachment has been copied to the SharePoint Library.

SharePoint

Select “Office 365 Outlook” as a connector.

Select “Office 365 Outlook – Send an email” as a trigger, this trigger is responsible for sending emails.

SharePoint

Choose or any valid email id in “To”, here I am just selecting the email for me.

Specify Subject as applicable.

Specify the Body content as required. This content can consist of dynamic tokens provided by Workflow runtime as shown below:

SharePoint

Save the Workflow and complete it.

In the following screens, we can see the complete workflow steps in one go:

Step 1

SharePoint

Step 2

SharePoint

Step 3

SharePoint

Now, let’s test the workflow by sending an email with attachments to myself.

SharePoint

Once I receive the email containing attachments in Inbox Folder, Workflow gets triggered.

SharePoint

Just after that we can see workflow entered into the debug mode as shown below-

SharePoint

And as soon as it is completed we can see the completion notification email as shown below-

SharePoint

And we can also see the attachments copied to the “Outlook Attachments” SharePoint Library as shown below-

SharePoint

Hope you find it helpful.

G
M
T
 
Text-to-speech function is limited to 200 characters