AutomateAlong

How-tos › Build a flow

How to save email attachments to SharePoint with Power Automate

Updated 2 November 2026

What this flow does: When an email with attachments arrives, save each PDF into a SharePoint folder and post a message in a Teams channel. When it works: Each PDF attachment lands in your Invoices folder with a date-stamped name, and a message appears in the chosen Teams channel.

Before you start

  • A Microsoft 365 account that can open make.powerautomate.com.
  • Connections to: Office 365 Outlook, SharePoint, Microsoft Teams. Power Automate asks you to sign in to each the first time you add a step from it.
  • Invoices arrive in your own Inbox.
  • Only attachments whose name ends in .pdf are saved.

The flow at a glance

  1. When a new email arrives · When a new email arrives (V3)
  2. For each attachment · Apply to each
  3. Inside the loop: Check if PDF · Condition
  4. If yes: Save PDF to SharePoint · Create file
  5. Notify finance channel · Post message in a chat or channel
  6. If the step before fails: Alert me if it fails · Send an email (V2)

Rename each step to the name shown. Expressions refer to steps by name, so a different name breaks them.

Build it step by step

1. When a new email arrives · Office 365 Outlook → When a new email arrives (V3)

Starts the flow for each new email that has attachments.

In Power Automate, select Create, then the flow type (Automated cloud flow), name it, and choose this trigger.

BoxValueHow it goes in
Folder
Choose from the dropdown
InboxOpen the dropdown and choose "Inbox". Pick the mailbox folder to watch.
Only with Attachments
Choose from the dropdown
YesOpen the dropdown and choose "Yes". Under Advanced parameters (Show all).
Include Attachments
Choose from the dropdown
YesOpen the dropdown and choose "Yes". Needed so attachment content reaches later steps.
Subject Filter
Your own value
invoiceType your own value; the example shows the format. Optional. Only emails whose subject contains this text start the flow.

2. For each attachment · Control → Apply to each

Repeats the inner steps once for every attachment.

Select + below the previous step, then Add an action, search for Control and select Apply to each. Rename it to For each attachment.

BoxValueHow it goes in
Select an output from previous steps
Dynamic content
⚡ AttachmentsClick in the box, select the lightning-bolt (Dynamic content) button, then under the trigger pick "Attachments".

3. Check if PDF · Control → Condition

Carries on only for files ending in .pdf.

Select + below the previous step (inside the loop), then Add an action, search for Control and select Condition. Rename it to Check if PDF.

BoxValueHow it goes in
Left value
Expression, in the fx box
toLower(items('For_each_attachment')?['name'])Click in the box, select the fx (Expression) button, paste it into the expression box, then select Add. Don't type it as plain text.
Operator
Choose from the dropdown
ends withOpen the dropdown and choose "ends with".
Right value
Type or paste it
.pdfClick in the box and paste it.

4. Save PDF to SharePoint · SharePoint → Create file

Creates the PDF in your Invoices folder.

Select + below the previous step (if yes), then Add an action, search for SharePoint and select Create file. Rename it to Save PDF to SharePoint.

BoxValueHow it goes in
Site Address
Your own site, list or folder
Your finance SharePoint sitePick your own from the dropdown (for example: Your finance SharePoint site). Pick the site from the dropdown.
Folder Path
Your own value
/Shared Documents/InvoicesType your own value; the example shows the format. Use the folder picker or type the path.
File Name
Expression, in the fx box
concat(formatDateTime(utcNow(), 'yyyyMMdd-HHmm'), '-', items('For_each_attachment')?['name'])Click in the box, select the fx (Expression) button, paste it into the expression box, then select Add. Don't type it as plain text. Adds a date stamp so file names stay unique.
File Content
Expression, in the fx box
base64ToBinary(items('For_each_attachment')?['contentBytes'])Click in the box, select the fx (Expression) button, paste it into the expression box, then select Add. Don't type it as plain text. Turns the attachment into file content.

5. Notify finance channel · Microsoft Teams → Post message in a chat or channel

Posts a short message about the saved invoice.

Select + below the previous step, then Add an action, search for Microsoft Teams and select Post message in a chat or channel. Rename it to Notify finance channel.

BoxValueHow it goes in
Post as
Choose from the dropdown
Flow botOpen the dropdown and choose "Flow bot".
Post in
Choose from the dropdown
ChannelOpen the dropdown and choose "Channel".
Team
Your own site, list or folder
Your finance teamPick your own from the dropdown (for example: Your finance team).
Channel
Your own site, list or folder
Your invoices channelPick your own from the dropdown (for example: Your invoices channel).
Message
Expression, in the fx box
concat('New invoice saved: ', items('For_each_attachment')?['name'], ' (from ', triggerOutputs()?['body/from'], ')')Click in the box, select the fx (Expression) button, paste it into the expression box, then select Add. Don't type it as plain text. Builds the message from the file name and sender.

6. Alert me if it fails · Office 365 Outlook → Send an email (V2)

Emails you if saving any attachment fails.

Select + below the previous step (if the step before fails), then Add an action, search for Office 365 Outlook and select Send an email (V2). Rename it to Alert me if it fails.

BoxValueHow it goes in
To
Your own value
you@yourcompany.co.ukType your own value; the example shows the format.
Subject
Type or paste it
Invoice flow failedClick in the box and paste it.
Body
Expression, in the fx box
concat('The invoice flow failed for the email: ', triggerOutputs()?['body/subject'])Click in the box, select the fx (Expression) button, paste it into the expression box, then select Add. Don't type it as plain text.

Test it

  1. Select Save, then Flow checker and fix anything it lists.
  2. Select Test → Manually → Test, then do the thing that starts the flow (send the email, submit the form, or run it).
  3. Open the run and check every step has a green tick. Then check the result: Each PDF attachment lands in your Invoices folder with a date-stamped name, and a message appears in the chosen Teams channel.
  4. If a step has a red cross, select it, copy the error and paste it into the Flow Doctor.

Things to watch

  • Images in email signatures count as attachments. The PDF check filters them out.
  • Inline Teams messages are posted once per PDF. An email with three PDFs posts three messages.

Or let AutomateAlong build it alongside you

This flow is a template in AutomateAlong: open it in the builder and it walks you through the same steps one at a time, with a Copy button on every value, readiness checks, and improvement ideas (error handling, duplicate checks) you can add with one click. Free, no card needed.

Related

AutomateAlong is independent and isn't affiliated with Microsoft. Microsoft and Power Automate are trademarks of the Microsoft group of companies.