Easy Tech Tuts
Power Automate

How to Automatically Save Email Attachments to OneDrive with Power Automate Easily 2026

By Impran M NLast checked against official docs

Dragging attachments out of email and into OneDrive by hand is the kind of task that's easy to fall behind on the moment your inbox gets busy. Power Automate can do it the instant an email arrives, and it can even sort attachments into different folders depending on who sent them. This guide follows a real flow built exactly that way: trigger on new email, branch true or false on a condition, then loop through and save each attachment, using the actual designer screens so you can see how the pieces connect, plus the one conversion step the designer doesn't warn you about until the flow fails.

Before you start

  • An Office 365 or Microsoft 365 mailbox already connected to Power Automate through the Outlook connector
  • A OneDrive for Business account authorized as a connection in the same environment

01Start an automated cloud flow and choose the email trigger

From Create, choose Automated cloud flow, which opens a "Build an automated cloud flow" dialog asking for a Flow name and a trigger. The trigger list is searchable and covers a wide range of events across SharePoint, OneDrive, and Outlook; for this flow, search for "When a new email arrives" and pick the Office 365 Outlook version.

Name the flow something you'll recognize later instead of leaving the auto-generated name, since a busy My flows list makes generic names hard to tell apart. Open the trigger's Advanced parameters and turn on Include Attachments. Without it, the trigger reports each attachment's name and size but not its content, and the OneDrive step later in this flow has nothing to write.

The Build an automated cloud flow dialog, with a searchable list of triggers including SharePoint and OneDrive events.
The Build an automated cloud flow dialog, with a searchable list of triggers including SharePoint and OneDrive events.

02Add a Condition to branch by sender

After the email trigger, this flow adds a Condition step that splits into a True branch and a False branch: in this case, checking whether the email came from inside the organization (pmnonline) or an outside customer. Branching before you even touch attachments means you can route internal files and external files to different destinations without building two separate flows.

03Add a OneDrive action and convert the attachment content

Inside the flow designer, search the action picker for "onedrive" to see the available actions: Create file, Copy file using path, Upload file from URL, and more. Create file is the one that matters here; it takes a folder path, a file name, and file content, and writes a new file into OneDrive.

Add a Create file action inside both the True and False branches of the earlier condition. The attachment content coming out of the Outlook trigger is a base64-encoded string, its ContentBytes property, not the binary data Create file's File Content field expects. Map File Content to the expression base64ToBinary(item()?['ContentBytes']) once you've built the loop in the next step, or Create file fails with "Parameter 'Attachment Content' cannot be null or empty."

The Add an action panel filtered to OneDrive actions, shown alongside the flow's Condition block with True and False branches ready to receive an action each.
The Add an action panel filtered to OneDrive actions, shown alongside the flow's Condition block with True and False branches ready to receive an action each.

04Loop through attachments with Apply to each

An email can carry more than one attachment, so each branch wraps its Create file action inside an Apply to each loop set to the trigger's Attachments output. In the finished flow this shows up as two clearly named loops: "Apply to each email attachment from pmnonline" feeding into "Create file in pmnonline," and "Apply to each email attachment from outside customer" feeding into "Create file for Customers." Inside the loop, File Name maps to item()?['Name'] and File Content maps to the base64ToBinary expression from the previous step. Naming loops and actions this specifically, instead of leaving Power Automate's defaults, makes the flow self-documenting when you or a teammate opens it months later.

The completed flow: an email trigger feeding a Condition, with each branch looping through attachments and creating a file in a different OneDrive location.
The completed flow: an email trigger feeding a Condition, with each branch looping through attachments and creating a file in a different OneDrive location.

05Set the destination folder and guard against duplicate names

Inside each Create file action, set the folder path to wherever that branch's files should land: an internal team folder for the True branch, a customer-facing intake folder for the False branch. Keeping the destinations separate at the flow level means nobody has to sort attachments by hand afterward.

Create file has no overwrite or rename option built in, unlike Copy file. If the same attachment name arrives twice, because a message got resent, OneDrive quietly creates a second file with that name instead of warning you. Add a Get file metadata check against the target folder before Create file, and append a timestamp to the new file's name when a match already exists.

When it doesn't work

Create file fails with "Parameter 'Attachment Content' cannot be null or empty."

Why: The attachment arrives from the Outlook trigger as a base64-encoded string (ContentBytes), and Create file's File Content field expects binary data, not text.

Fix: Wrap the value in the expression base64ToBinary(item()?['ContentBytes']) when you map File Content inside the Apply to each loop.

The flow times out, or attachments come through empty, when several emails land at once.

Why: Microsoft's own troubleshooting notes that Include Attachments = Yes makes the trigger wait for every attachment to download before it fires, which can time out under a burst of mail.

Fix: Set Include Attachments to No on the trigger instead, and add a separate Get attachment (V2) action inside the Apply to each loop to fetch each file's content on demand.

The same attachment shows up twice in OneDrive.

Why: Create file doesn't check for an existing file of the same name the way Copy file does; it just creates a second one.

Fix: Check for an existing file with Get file metadata before Create file runs, and append a timestamp to the name if one is already there.

FAQ

Frequently asked questions

Do I need to convert the attachment before saving it?

Yes. The trigger hands you a base64 string, not the file itself. Wrap it in base64ToBinary(item()?['ContentBytes']) before mapping it to Create file's File Content field, or the action errors out.

Can I choose which OneDrive folder attachments go into?

Yes. Each Create file action specifies its own destination folder, and this flow uses two different folders depending on which branch of the Condition an email falls into.

Will this work with multiple attachments in one email?

Yes. Each branch wraps its Create file action inside an Apply to each loop over the trigger's Attachments output, so every attachment in the email gets saved individually.

Can I filter out emails I don't want processed?

Yes. Beyond the Condition used here to branch by sender, the email trigger's own Advanced parameters let you filter by sender, subject, or folder so irrelevant emails never enter the flow.

How do I stop the same attachment from being saved twice?

Add a Get file metadata check against the destination folder before Create file, and append a timestamp to the filename if a match already exists. Create file itself won't catch this for you.

Why use a Condition to branch instead of one Create file action?

Branching lets you route attachments to different folders based on who sent the email, internal senders to one location, outside customers to another, without maintaining two separate flows.

Sources and last check

Click path and screens come from a recorded walkthrough of a real flow: the trigger, the condition, and the OneDrive branches. The Create file parameter list, the base64ToBinary conversion requirement, and the Include Attachments timeout behavior were checked against Microsoft's OneDrive connector reference and its Outlook email troubleshooting page in September 2026. The earlier draft never mentioned that ContentBytes needs converting before Create file will accept it, a gap that makes the flow fail outright, not just look incomplete.

About the author

Impran M N
Written by

Impran M N

I've been hooked on technology for as long as I can remember — especially the new tools and AI apps that seem to land every other week. Easy Tech Tuts is where I write up whatever I've just worked out: I do the task in the real product, record the screen, and turn it into the guide I wish I'd found first.