Posted on

Power Automate Tutorial: Save Email Attachments to SharePoint (with Conditions)

One of the most common requests in any IT department is: “Can we stop saving email attachments manually?”

Whether it’s invoices from vendors, reports from automated systems, or project files from clients, manual filing is prone to error and incredibly boring. Fortunately, Power Automate makes this trivial to solve.

In this guide, we will build a robust flow that doesn’t just “dump everything,” but intelligently files attachments based on criteria.

The Goal

We want a flow that:
1. Triggers when a specific email arrives (e.g., from invoices@vendor.com).
2. Checks if it has attachments.
3. Filters out junk (like signature images).
4. Saves the valid file to a specific SharePoint Document Library.

Step 1: Create the Trigger

  1. Go to make.powerautomate.com.
  2. Create a Automated cloud flow.
  3. Search for the trigger: “When a new email arrives (V3)” (Office 365 Outlook).
  4. Important: Click “Show advanced options”.
    • Include Attachments: Set to Yes.
    • Only with Attachments: Set to Yes.
    • Subject Filter: Enter “Invoice” (optional, but good for filtering).

Step 2: The Loop

Because an email can have multiple attachments, Power Automate automatically puts the next steps into an “Apply to each” loop.

  1. Add a new action: “Apply to each”.
  2. Select the Attachments dynamic content from the email trigger.

Step 3: Filtering the Junk

We don’t want to save every image001.png from someone’s email signature.

  1. Inside the loop, add a Condition.
  2. Set the condition: Attachment Is Inline is equal to false.
    • Note: Sometimes “Is Inline” isn’t enough. You might check Content-Type does not contain image/.

Step 4: Create File in SharePoint

If the condition is True (it’s not an inline image), we save it.

  1. In the “If yes” branch, add an action: “Create file” (SharePoint).
  2. Site Address: Select your SharePoint site.
  3. Folder Path: Choose the destination folder (e.g., /Shared Documents/Invoices/).
  4. File Name: Select Attachments Name from dynamic content.
  5. File Content: Select Attachments Content from dynamic content.

Step 5: Handling Duplicate Names

What happens if you receive two files named Invoice.pdf? The flow will fail by default.

To fix this, go to the Settings of the “Create file” action (the three dots ...).
* Turn off “Fail on error” isn’t the right way.
* Instead, change “File Name” to include a unique ID, like: @{triggerOutputs()?['body/receivedDateTime']}_@{items('Apply_to_each')?['name']}.
* Or use the “Move file” action later to rename it.

For simple flows, just appending the “Received Time” to the filename is the easiest robust solution.

Testing

  1. Click Test (top right) -> Manually.
  2. Send yourself an email with an attachment (matches your subject filter if you set one).
  3. Watch the flow run Green!

You now have a permanent, automated archive of your critical documents.