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 with adding a document library to SharePoint site, let’s call it “Outlook Attachments”
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 document library so 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 trigger to kick off this workflow
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.
Set “Has Attachment” = Yes, this settings will further filter out the incoming emails based on if they have attachments or not.
We are only monitoring only emails with attachments and that’s what these filter will achieve for us.
Set “Include Attachments” = Yes, this is required so that Workflow runtime include the binary information of each the attachments and make it available to be written to SharePoint Library.
Add another action with “SharePoint” as connector
Select “SharePoint – Create file” as trigger, this action will be responsible to write down the attachment binaries to SharePoint Library
Enter Site URL where we have “Outlook Attachments” document library sitting
Select document library name from the lookup in the Folder Path Field
Select “Name” property in the File Name field, this property represents the name of the attachment
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 does not set the “Include Attachments” = Yes, then Content property will be null and will cause not write operations takes place
Add another action to the workflow, which will be responsible to send email after the attachment has been copied to the SharePoint Library
Select “Office 365 Outlook” as connector
Select “Office 365 Outlook – Send an email” as trigger, this trigger is responsible for sending emails
Choose or any valid email id in “To”, here I am just selecting the email of 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-
Saves the Workflow and complete it.
In the following screens we can see the complete workflow steps in one go-
Now let’s test the workflow by sending an email with attachments to myself.
Once I received the email containing attachments in Inbox Folder, Workflow gets triggered
Just after that we can see workflow entered into the debug mode as shown below-
And as soon as it is completed we can see the completion notification email as shown below-
And we can also see the attachments copied to the “Outlook Attachments” SharePoint Library as shown below-
Hope you find it helpful.