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:
- A trigger that fires when a matching email arrives.
- A loop that handles each attachment, because one email can carry several.
- A check that skips signature logos and other inline pictures.
- A SharePoint step that saves the file with a name that will not clash.
Before you start
- Pick the library first. In SharePoint, make a document library, or a folder inside one, for these files. Microsoft's page for the SharePoint connector says of the Create file action: "Uploads a file to a SharePoint site. Make sure to pick an existing library."
- Decide which emails count. Saving every attachment from every sender fills the library with noise. One way to start: save only mail from a set of senders, or only mail with a word in the subject.
- Check that your account can add files to that library, and ask your admin which Power Automate plan covers your flow. Plans differ by organization.
- Sign in to https://make.powerautomate.com with the work account that owns the mailbox.
Step 1. Add the trigger
- In Power Automate, create an automated cloud flow.
- Choose the Outlook trigger "When a new email arrives (V3)". Exact names may differ in your version.
- 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.
- 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."
- 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:
- Choose the "Is Inline" value from the dynamic content for the current attachment.
- Set the operator to "is equal to" and the value to false.
- 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.
- 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.
- 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."
- 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().
Step 7. Keep names legal
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
- The trigger skips some mail. Microsoft says it "will skip any email that has a total message size greater than the limit put by your Exchange Admin or 50 MB, whichever is less. It may also skip protected emails and emails with invalid body or attachments."
- Files in the SharePoint connector have a size cap. Microsoft says: "This connector supports file sizes up to 100 MB." It adds: "Uploads or downloads for larger files might fail due to buffer size limits."
- Do not use this flow for secret files without asking who can open the library. A library is a place where people with access can read files. Views and folders are not security.
What to avoid
- Do not save from every sender with no filter. The library fills with junk.
- Do not turn "Include Attachments" on for a busy mailbox. Microsoft names timeouts as a risk.
- Do not skip the Condition for inline files. You will collect signature logos.
- Do not point the flow at a library that does not exist. The Create file page says the folder path "Must start with an existing library."
- Do not run the flow from a personal account that may close. See "Flow fails because the connection expired: how to fix it".
- Do not forget to test with an email that has two attachments, one inline picture and one real file.
Test the flow
- Send yourself an email with two real attachments and a signature logo.
- Open https://make.powerautomate.com and open the run history for the flow.
- Check that each real file shows in the library once and the logo does not.
- Send the same two files again and check that the new names differ from the first set.
- 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.
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
- Microsoft Learn, Microsoft 365 Outlook connector
- Microsoft Learn, SharePoint connector
- Microsoft Learn, Apply to each action
- Microsoft Learn, Azure Logic Apps workflow expression functions reference
- Microsoft Support, Restrictions and limitations in OneDrive and SharePoint