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 / Create file (SharePoin...
Power Automate
Suggested Answer

Create file (SharePoint) is creating corrupted files from Email attachment

(0) ShareShare
ReportReport
Posted on by 3
Hi Power Automate community, 
 
I have an issue with the Create file (SharePoint) connecter within my Power Automate workflow. Currently, there is a production instance of a power automate workflow that works successfully. The automated cloud workflow is triggered using the "When a new email arrives in a shared mailbox (V2)" which looks for a specific Subject Filter, and emails with Attachments, and includes the attachments. The workflow then initializes several variables from the email itself to be used later on for adding variables to file names, etc. The production workflow successfully creates Excel files in the designated SharePoint location (and can be opened). 
 
I want to update the workflow to validate the headers on the excel files being attached to the emails. I created a duplicate workflow and adjusted only the Subject Filter in the trigger, and the folder in the create file configuration. However, when testing this development workflow, the create file tool is succeeding on the surface, but the Excel file in the SharePoint is corrupted. When I try to open the file it has the following error: 
 
"Couldn't open the workbook: This workbook couldn't be opened because the file format may not be matching with the file extension."
 
Troubleshooting: 
  • I've ensured the attachment is truly an excel file (.xlsx format) and have already tried other formats (.xls, .csv, txt) but none of these change.
  • I've ensured this excel file is the only attachment on the email
  • There are no formatted tables or macros on this excel file. It is just a very simple table with headers in the first row. 
  • The Create file parameter "File Content" utilizes the "When a new email arrives in a shared mailbox (V2)" tool's dynamic "Attachments Content" variable.
I've reviewed this workflow with other members on my team who have experience using Power Automate and we cannot seem to figure out why this tool creates files successfully in one workflow, but only creates corrupted files in another workflow. Please let me know if I can provide any additional information. Thank you in advance.
Screenshot 2026-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,204 Super User 2026 Season 1 on at

    Hi 👋

    This issue is very common in Power Automate, and the good news is  it’s usually not an Excel problem. It’s a file content handling issue in the flow.

     

    After trigger
    1)Add Apply to each
    In the input, choose:
    Attachments
    2) Inside Apply to each
    Inside the loop:
    Add Action:
    Create file (SharePoint)
    Configure like this:
    File Name → Name (from attachment dynamic content)
    File Content → ContentBytes (NOT Attachments Content)
    This is important:
    Use ContentBytes, not Attachments Content.
     

    Attachments Content = full collection (can corrupt file)

    ContentBytes = actual binary file content (correct format)

     
    If still fails 

    use compose: items('Apply_to_each')?['ContentBytes']
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
     
  • TW-21020002-0 Profile Picture
    3 on at
    Hi @Riyaz_riz11, thank you for your response! I was utilizing the "Apply to Each"
    item()?[contentBytes]
    Which seemed to work. Additionally, one nuance that resolved this issue was creating a new folder in the SharePoint file using the same credentials as the Connection in Power Automate, and this allowed me to read/write the file successfully. Thank you!

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 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard