How to turn an email attachment into file content in Power Automate
Updated 2 November 2026
The expression:
base64ToBinary(items('For_each_attachment')?['contentBytes'])Turns the attachment's base64 text into real file content.
Where it goes
The File Content box of Create file, inside a loop over the email's attachments.
- In the Power Automate designer, click in the box that needs the value.
- Select the fx (Expression) button that appears next to the dynamic content list.
- Paste the expression and select Add. It should appear as a purple fx chip; if you can see it written out as text, it went in as plain text and won't run.
Example output
(binary file content) (illustrative; AutomateAlong doesn't run expressions)
The common mistake
items('For_each_attachment')?['contentBytes']Passed straight to Create file, the file saves but won't open: it's the base64 text, not the file. base64ToBinary() turns it back into the file.
Before you rely on it
- Include Attachments is Yes on the trigger.
Change it for your flow
Step names inside an expression must match your steps exactly, with underscores for spaces: Get_items, not Get items. To adapt it, open it in the Expressions checker, which points at any bracket, quote or name that's wrong and suggests the corrected version. To write a different one from plain English, describe what you need on the same page.
Related
- How to get a link to the current flow run in Power Automate
- How to get the flow's own name in a Power Automate expression
AutomateAlong is independent and isn't affiliated with Microsoft. Microsoft and Power Automate are trademarks of the Microsoft group of companies.