Send email attachments to SharePoint Online

Sometimes it makes a lot of sense to send a document as an email attachment and have it saved to a SharePoint document library.  A common scenario is emailing a scanned document from a network copier to a SharePoint document library.  For those using SharePoint on-premises there is the incoming email service that can establish an email-enabled list. If your organization is using Office 365 and SharePoint Online it is not so easy.  Office 365 and SharePoint Online do not have the ability to create a list or library that has an email address.

Microsoft has recently developed a new product called Microsoft Flow. Flow is a cloud-based workflow engine that can connect to a variety of common cloud services to provide notifications, manipulate data, and automate processes. In this post, I will demonstrate using an Exchange Online mailbox to receive emails and then use Microsoft Flow to extract email attachments and drop them in a SharePoint document library.  This will provide the ability to “email a document” to a SharePoint Online document library in Office 365.


Create a New User in Office 365

We need to establish a new mailbox in Exchange Online to receive the emails.  A shared mailbox will not work because there is not a user associated with it to login.  Flow will need to login to both Exchange and SharePoint as a user that has a license for both products.  There is not a Flow activity (yet) to connect to a shared mailbox requiring us to use the logged in user’s mailbox.  As a best practice, it is not a good idea to mix an actual user’s mailbox with one we will use for automated document routing.  Therefore, we will need to create a new licensed user in Office 365.  However, we do not need to establish a new user for each document library that we want to send emails to.  We will create a single mailbox with multiple email addresses that will handle routing to multiple document libraries.  In this article, I will demonstrate using a single account for multiple document routes to SharePoint Online.

We will first create a new user with a generic email address (not the address we will use to route documents).

Create User Account

When assigning licenses, you only need to activate Exchange Online and SharePoint Online.

SharePoint and Exchange E1 Licenses


Create an Alias For Each Document Route

We may have multiple destination document libraries, each with a dedicated email address.  For example, when an email is sent to [email protected] we would like those documents to be placed in the Expense Reports library in the Finance department team site.  When an email is sent to [email protected] those documents should be placed in the Documents library in the Marketing team site.

We will use a single, underlying mailbox to receive all emails that will be routed to SharePoint, regardless of the destination.  To do this, we will give the mailbox an email alias for each route.

Open Exchange Properties

Add Email Alias

We can now send emails to this mailbox using an email address of [email protected]


Email Folders and Inbox Rules

We will need to sort the email into folders so that Flow will be able to route the emails to SharePoint appropriately (later in this article). For each route, we will create a folder and an Inbox rule to move emails into the correct folder as they arrive.  You will need to log into Outlook Web Access as the new user you created earlier. Once you are logged in you can create a folder for the route and the matching Inbox rule to move messages into the correct folder.

Create Folder

Create Inbox Folder

When creating the Inbox rule we will match messages based upon values in the message header instead of the To address.  Exchange Online modifies the To field of messages to match the name of the user account, which removes the original address from the To field.  The message header will retain the original To address so we will use that when creating our rule.

Open Mailbox Settings

Create Inbox Rule: Include Words In Header

Create Inbox Rule: Email Alias

Create Inbox Rule: Move To Folder

Create Inbox Rule: Select Folder

Once you have specified the settings for the rule, click OK.  Now, whenever a message is sent to [email protected] it will be placed into the Expense Reports folder.


Grant Permissions In The Destination SharePoint Library

To save a document in the desired SharePoint document library the SharePoint Distribution account must be granted access.  Browse to the document library where the attachments will be saved. Use the Share feature and grant contribute access to the SharePoint Distribution user account.

Share Document Library


Create a Microsoft Flow to Move Email Attachments To SharePoint

To create a Microsoft Flow browse to and login with the SharePoint Distribution account that you created earlier. We will use an existing Flow template that will extract attachments from new emails that have been moved to the new folder that was created.  The Flow will then save the attachment to the destination SharePoint document library.

To create the flow, start by using the search templates… box at the top of the screen and search for “email sharepoint”.

Select Flow Template

In the template results, select the template called Save my email attachments to a SharePoint document library.

Select Flow Template

Next, you will need to click Use this template and log in to both the Office 365 Outlook and SharePoint Online connectors.  After clicking each of the Sign in buttons a dialog will briefly open, just wait and it will close once Flow has completed the sign in.

Flow: Use this Template and Sign In

Start with the action for On new email.  Enter the name of the mailbox folder that you created earlier.

Flow: On new Email

Next, select the SharePoint site and library where attachments will be saved.

Flow: Select SharePoint Site and Library

At this point, the Flow is configured to save attachments to the Expense Reports document library when new messages arrive in the Expense Reports mailbox folder. Once the attachments are saved, we can optionally remove the original message from the mailbox.  We will add a new Office 365 Outlook – Delete email step to clean up the message.  At the bottom of the Flow, click New step. Then, Add an action and search for Delete email.

Flow: Add Step

Flow: Find Delete Email Actions

Configure the action to use the Message Id output of the On new email action to delete the message.

Flow: Delete Message Action

The completed Flow should look like this.  Now, give your Flow a name and click Create Flow.

Flow: Complete Save Attachment to SharePoint


Start Sending Messages

You are now ready to start sending messages.  All you need to do is to configure your multi-function copier, reporting application, or whatever else that you want to send emails with attachments from and they will end up in your SharePoint document library.


Set Up Additional Routes

You can set up routes to other document libraries.  You will use the same mailbox and Flow account.  To add additional routes you will need to:

  1. Add an alias to the SharePoint Distribution user mailbox.
  2. Create a new folder and Inbox rule to sort messages using the email address in the message header.
  3. Grant permissions to your destination document library.
  4. Create a new flow.


  1. Tom Franks says:

    This is interesting, but was this a very early version of flow? I no longer see an Office 365 Outlook Delete Email action in the flow list of actions.

    Also, do you think it would be possible to use the email subject to direct to the doc lib and folder by specifying an email subject of “shared documents/folder a” or something similar?

    1. Travis Lingenfelder says:

      Yes the article was written when Flow was in a preview state and there have been a few changes so that the process shown here will not work without some modification. At some point I want to revisit this post and update it to reflect the current state of the platform.

      Flow does offer some conditional logic so routing documents may be possible.

  2. Dave G says:

    I’d be interested in an update on this post. This would extend and help grow our current sharepoint implementation

  3. Victor Espinoza says:

    Hello! I was wondering @ Email Folders and Inbox Rules step, where did you get SharePoint distribution. Is this a folder you created? Or is it something that came with outlook already? Could you please tell me

  4. Victor Espinoza says:

    No worries I see where did it come from.

  5. Scot Tomlinson says:

    Very interesting but can the process be made to drop the attachments in a specific folder (not SharePoint) on a specific server? We have a electronic document management system that will pick up the attachments from a folder and begin processing them.

  6. Ken Nguyen says:

    thank you for this great information. I do have one problem, where the message header do not retains the original sent to email address, it is replaced by the main email address when the email was sent internally. if the email was sent from an outside email address then this works.

    Do you know a way around this problem?



  7. Mike Gusway says:

    As an update to my last comment (which I don’t see posted here yet), if I send a message to the alias address from a Gmail account, it gets moved to the proper folder. Attaching a file to a test email from Gmail works exactly as intended, including the message deletion after the attachment gets saved to the SharePoint library. When sending to the alias address from my company O365 mail account, the alias address is getting replaced with the generic address in the message header, so the mail rule doesn’t apply and the message just sits in the top-level Inbox of the generic account.

Post a comment