← Al Davies, 250 High Street

Save email attachments to SharePoint automatically

Short answer: use the Outlook trigger "When a new email arrives (V3)" with "Only with Attachments" set to Yes, loop over the attachments, skip the ones marked inline, and send the rest to the SharePoint action "Create file". Add the time to each file name so two files with the same name do not collide. You build it at https://make.powerautomate.com.

What the flow does

Someone emails you an invoice, a signed form or a photo. Today you open the email, save the file, find the right folder and drop it in. The flow does that for you. Each new email with an attachment sends its files to one SharePoint library. Nobody has to remember.

The flow has four parts:

  1. A trigger that fires when a matching email arrives.
  2. A loop that handles each attachment, because one email can carry several.
  3. A check that skips signature logos and other inline pictures.
  4. A SharePoint step that saves the file with a name that will not clash.

Before you start

Step 1. Add the trigger

  1. In Power Automate, create an automated cloud flow.
  2. Choose the Outlook trigger "When a new email arrives (V3)". Exact names may differ in your version.
  3. Set the filters. Microsoft's Outlook connector page lists these trigger fields: Folder, To, CC, To or CC, From, Importance, Only with Attachments, Include Attachments and Subject Filter.
  4. Set "Only with Attachments" to Yes. Microsoft describes it this way: "If set to true, only emails with an attachment will be retrieved. Emails without any attachments will be skipped. If set to false, all emails will be retrieved."
  5. Use "From" and "Subject Filter" to narrow the mail. Microsoft describes From as "Sender email addresses separated by semicolons (If any match, the trigger will run)." and Subject Filter as "String to look for in the subject line."

Step 2. Leave "Include Attachments" off

It looks natural to turn "Include Attachments" on. Microsoft's Outlook connector page warns about it in its list of known issues: "Setting Include Attachments to Yes causes the connector to wait for all attachments to be downloaded." It adds: "When many emails with attachments arrive around the same time, the connector can timeout while downloading these attachments." And it gives this fix: "To avoid this, the trigger should be changed to set Include Attachments to No, and the logic should be changed to add the Get Attachment (V2) action to download the attachment."

So the plan is: set "Include Attachments" to No in the trigger, then fetch each file inside the loop. The same page explains that this setting "controls only attachments content, but not the attachments metadata (like Id, Name, Content Type, Size, and Is Inline), which would be included in the response regardless of the parameter value." That means you still get the name, the size and the inline flag for each attachment without the download.

Step 3. Loop over the attachments

One email can have zero, one or many files. Add an "Apply to each" action and pick the attachments list from the trigger's dynamic content. Inside the loop, every step runs once per file.

Microsoft's Apply to each page says the action is used "to process a list of items". The loop must wrap the next steps.

Step 4. Skip signature pictures

Signatures often hold small logo images. If you save every attachment, those logos land in your library too. The Outlook connector page says the attachment info includes "Is Inline" with the text "Set to true if this is an inline attachment."

Inside the loop, add a Condition that checks the attachment's "Is Inline" value:

  1. Choose the "Is Inline" value from the dynamic content for the current attachment.
  2. Set the operator to "is equal to" and the value to false.
  3. Put the save steps in the "If yes" branch. Leave "If no" empty.

Our advice, not a Microsoft rule: also skip very small image files, because some signature images are not marked inline. A second Condition on the attachment name or size is one way to start. Review what lands in the library for a week and adjust.

Step 5. Download and save the file

In the "If yes" branch, add two actions.

  1. Add the Outlook action "Get Attachment (V2)". Microsoft describes it as "This operation gets an email attachment by id." It needs two values. Message Id is described as "Id of the email." The second is "Id of the attachment to download." Use the trigger's Message Id and the current attachment's Id from the loop.
  2. Add the SharePoint action "Create file". Microsoft's page lists four fields. Site Address, with the example "https://contoso.sharepoint.com/sites/sitename". Folder Path, described as "Must start with an existing library. Add folders if needed." File Name, described as "Name of the file." File Content, described as "Content of the file."
  3. For File Content, use the content from the Get Attachment (V2) step.

Step 6. Make file names unique

Two people can send "scan.pdf" on the same day. Our advice, not a Microsoft rule: put the date and time in front of the original name, so each file name is new.

Build the File Name with an expression. Microsoft's Logic Apps expression reference says formatDateTime will "Return a timestamp in the specified format." and utcNow will "Return the current timestamp as a string." The same reference says concat will "Combine two or more strings, and return the combined string."

One way to write the File Name:

concat(formatDateTime(utcNow(), 'yyyyMMdd-HHmmss'), '-', items('Apply_to_each')?['name'])

The loop name inside items() must match the name of your loop. If you renamed it, use the new name with underscores for spaces.

Our advice, not a Microsoft rule: if you want the received time and not the time the flow ran, use the email's received time from the trigger instead of utcNow().

SharePoint file names cannot hold some characters. Microsoft's support page on OneDrive and SharePoint limits says: "The following characters aren't allowed in file and folder names in OneDrive for home or OneDrive for work or school:" The listed characters are the double quote, asterisk, colon, less than, greater than, question mark, slash, backslash and vertical bar. A sender can attach a file with one of those marks if it came from another system.

Our advice, not a Microsoft rule: test with a file whose name has a colon or a question mark and see what your flow does. If it fails, add a replace() step to swap each bad character for a dash.

Step 8. Add structure to the library

A pile of files is hard to search. One way to start is to add columns to the library, such as Sender and Received date, and fill them with a second action. Microsoft's SharePoint connector page describes "Update file properties" as an action that "Updates the properties stored in columns in a library for the item specified by the item id." Add it after Create file, using the ID that Create file returns.

If you want to sort files by type of document, add a Choice column with number prefixes (1 Invoice, 2 Contract, 3 Other). The prefix keeps your order. A Choice column sorts by its text.

Limits to know

What to avoid

Test the flow

  1. Send yourself an email with two real attachments and a signature logo.
  2. Open https://make.powerautomate.com and open the run history for the flow.
  3. Check that each real file shows in the library once and the logo does not.
  4. Send the same two files again and check that the new names differ from the first set.
  5. Look at a failed run, if any, and read the error on the step that failed.

If a later step hits a lock on the file, see Fix "file is locked for shared use" in Power Automate.

When to get help

You can build all of this yourself in Microsoft 365. If you would rather have it built and tested for your team, I do that. A tracker like this is a fixed price: $5,000 for one, built in 2 weeks. See "What a SharePoint tracker costs to build". Bring one example of the problem to a free call.

Tell me what's still manual

I am Al Davies. I run 250 High Street LLC and build SharePoint trackers and Power Automate flows for operations teams. I work remotely. The first call is free, and I will not try to sell you anything.

See trackers I built: Tools I built

FAQ

Do I need "Include Attachments" set to Yes?

No. Microsoft's Outlook connector page says that with many attachments arriving together the connector can time out, and it advises setting Include Attachments to No and using the Get Attachment (V2) action to download each file.

How do I stop signature images from being saved?

Add a Condition inside the loop that checks that "Is Inline" is false. Microsoft describes the field as "Set to true if this is an inline attachment." Our advice, not a Microsoft rule: also check file size, since not every signature picture is flagged inline.

What if two attachments have the same name?

Our advice, not a Microsoft rule: add the date and time to the front of each file name with formatDateTime and concat, so every saved name is new.

Can the flow save files into a different folder for each sender?

Yes. The Create file step takes a Folder Path, and Microsoft says it "Must start with an existing library. Add folders if needed." Build the path from the sender value. Our advice, not a Microsoft rule: create the folder first with the SharePoint action "Create new folder", which Microsoft describes as one that "Creates a new folder or folder path."

Does the flow also work for a shared mailbox?

Our advice, not a Microsoft rule: ask your admin which account should own the trigger before you build. For the sending side of a shared mailbox, see "Send Power Automate emails from a shared mailbox".

Sources