web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Attached documents fail
Power Automate
Answered

Attached documents fail

(0) ShareShare
ReportReport
Posted on by 6

I am currently working on a Power Automate flow where the objective is to automate the handling of email attachments.

The flow is designed to work as follows:


  • The flow is triggered every time a new email arrives with attachments.

  • The attachments are extracted automatically from the email.

  • The extracted files are then saved into a specific folder in SharePoint.

  •  

The flow runs successfully without errors, and the files are created in the SharePoint library as expected. However, I am facing an issue specifically with Excel files (.xlsx).

When I try to open the Excel file directly from SharePoint, I receive the following error message:

 

"This workbook couldn't be opened because the file format may not be matching with the file extension."

This behavior suggests that although the file is saved with the correct .xlsx extension, the actual content of the file appears to be corrupted or does not match the expected Excel format.

The same file opens correctly when it is downloaded directly from the original email attachment, but not when it is generated through the Power Automate flow and stored in SharePoint.

At this point, I am not certain what is causing the file corruption. The issue may be related to how the attachment content is being retrieved or passed into the "Create file" action in SharePoint (for example, using an incorrect attachment content field such as contentBytes instead of the correct attachment content output).

Categories:
I have the same question (0)
  • Suggested answer
    Soufyane Profile Picture
    69 on at

    Hi 
    In your Create file action in SharePoint, you're most likely passing the raw attachment output directly as the file content. For email attachments, the content comes as base64 encoded — you need to decode it first.

    Change your file content field to:

    base64ToBinary(triggerOutputs()?['body/attachments/0/contentBytes'])

    Or if you're looping through attachments:

    base64ToBinary(items('Apply_to_each')?['contentBytes'])

    That's almost certainly what's corrupting the file. The xlsx is being saved as raw base64 text instead of actual binary content.

     

    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.

    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Soufyane and I’ll be happy to assist.

    💛 A Like always motivates me to keep contributing!

     

  • EG-07041735-0 Profile Picture
    6 on at
    @Soufyane

    Thanks for your help but this is what im seeing rigth now in the flow 
  • Ellis Karim Profile Picture
    12,122 Super User 2026 Season 1 on at
     
     
    A work around to the issue is to use a compose action to store the file content type and file content. Then use the output of the Compose action for the File Content in the SharePoint Create file action:
     
    Ellis Karim
    Ellis Karim
    elliskarim.com  |  LinkedIn  |  Bluesky
    If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 471

#2
11manish Profile Picture

11manish 246

#3
David_MA Profile Picture

David_MA 238 Super User 2026 Season 1

Last 30 days Overall leaderboard