Automations 5 min

Save Outlook Attachments with Power Automate

Short answer

You can automatically save Outlook email attachments to SharePoint or OneDrive with a Power Automate cloud flow. Use the 'When a new email arrives (V3)' trigger with the attachment filter enabled, then add a 'Get attachments (V2)' action followed by an 'Apply to each' loop that calls 'Create file' for every attachment. The whole flow takes about ten minutes to set up and requires no code.

Automatically save email attachments from Outlook to SharePoint or OneDrive using a Power Automate cloud flow.

Why Automate Attachment Saving?

Manually downloading email attachments and uploading them to a shared folder is one of the most common repetitive office tasks. It is easy to forget, creates inconsistent naming, and means files live in individual inboxes rather than in a shared location where colleagues can find them.

A Power Automate flow runs within seconds of the email arriving, saves every attachment with a consistent name, and puts it in the right SharePoint folder automatically. Typical use cases include saving incoming invoices from a supplier, collecting completed forms submitted by customers, and archiving delivery confirmations from logistics partners.

The flow described below works for Microsoft 365 accounts and requires a Power Automate licence (included in most Microsoft 365 Business plans).

Setting Up the Trigger

Open Power Automate at make.powerautomate.com and create a new Automated cloud flow. Search for the trigger “When a new email arrives (V3)” and select the Outlook connector.

In the trigger settings, set Only with attachments to Yes. This prevents the flow from running on emails that have no attachments, which avoids unnecessary executions and keeps your run history clean.

You can optionally add filters for From (a specific email address or domain) or Subject filter (a keyword that must appear in the subject line). For example, filtering on from:invoices@supplier.com ensures only that supplier’s emails trigger the flow, not every email your inbox receives.

For more advanced filtering later, such as routing different attachment types to different folders, see error handling in Power Automate for patterns that handle conditional logic gracefully.

Retrieving Attachments and Saving Files

After the trigger, add the action Get attachments (V2) from the Outlook connector. In the Message Id field, select the dynamic value “Message Id” from the trigger. This action returns a list of all attachments on the email, including their names and content.

Next, add a Control: Apply to each loop. Set its input to the value output of the “Get attachments” action. This loop runs once per attachment.

Inside the loop, add the Create file action from either SharePoint or OneDrive, depending on where you want the files stored. Fill in:

  • Site Address (SharePoint) or Folder Path (OneDrive): the destination location
  • File Name: select the dynamic value Name from the “Get attachments” output
  • File Content: select the dynamic value Content Bytes from the “Get attachments” output

The “Content Bytes” value contains the actual binary content of the file, which is what the “Create file” action needs to write the file correctly.

Organising Files with Dynamic Folder Paths

A flat folder of attachments becomes hard to navigate quickly. You can make the destination folder dynamic so attachments are automatically sorted.

To organise by month, set the Folder Path to:

/Invoices/{{formatDateTime(utcNow(), 'yyyy-MM')}}

To organise by sender email address:

/Attachments/{{triggerOutputs()?['body/from']}}

SharePoint creates the subfolder automatically if it does not exist, so you do not need to pre-create folder structures for every month or sender.

Testing and Activating the Flow

Before activating the flow in production, test it. Send an email with one or two attachments to the inbox connected to the trigger. Then open the flow in Power Automate, click Test, and choose Manually to trigger a test run immediately.

Watch the run detail page: each step shows a green tick if it succeeded or a red cross if it failed, along with the inputs and outputs of that step. Verify that the correct number of files appears in your SharePoint folder with the expected names.

Once the test succeeds, the flow is live and will run automatically on every new email that matches your filters. You can monitor runs in the Run history tab and set up email notifications for failures via error handling in Power Automate.

Our tip: Add the attachment’s original email subject as a prefix to the filename, using the expression concat(triggerOutputs()?['body/subject'], ' - ', items('Apply_to_each')?['name']). This makes it easy to trace any saved file back to the email it came from, which is invaluable when auditing invoices or contracts months later.

Frequently asked questions

Can I filter which attachments get saved based on file type?

Yes, you can add a Condition step inside the 'Apply to each' loop. Use the expression `endsWith(items('Apply_to_each')?['name'], '.pdf')` to check the file extension before the 'Create file' action runs. This way, only files matching the condition are saved. You can combine multiple conditions with OR logic to accept several file types, such as PDF, XLSX, and DOCX. The 'Name' property of the attachment always contains the original filename including the extension.

What if two attachments have the same name?

The SharePoint 'Create file' action has a setting called 'If file exists' that you can set to 'Replace', 'Rename', or 'Fail'. Setting it to 'Rename' is usually safest: SharePoint adds a number suffix (for example, `invoice (1).pdf`) so no file is ever overwritten silently. Alternatively, you can prefix the filename with a timestamp using the expression `concat(formatDateTime(utcNow(), 'yyyy-MM-dd_HHmm'), '_', items('Apply_to_each')?['name'])` to guarantee uniqueness.

How do I organise attachments into subfolders by sender or date?

In the 'Create file' action, the folder path field accepts dynamic values. You can build a dynamic path like `/Invoices/{{triggerOutputs()?['body/from']}}` to create a subfolder per sender, or `/Invoices/{{formatDateTime(utcNow(), 'yyyy/MM')}}` to organise files by year and month. SharePoint creates the subfolder automatically if it does not yet exist. This is one of the most practical ways to keep a shared document library organised without any manual filing.

Want a dashboard or automation built for you?

Stuurboard BI builds custom Power BI dashboards and workflow automations. Pragmatic, fast, and without the fuss.