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 / Power Automate doesn't...
Power Automate
Suggested Answer

Power Automate doesn't save attachments correctly

(2) ShareShare
ReportReport
Posted on by 4
Hi,
 
I used a template to save attachments when an e-mail arrives to an specific folder in OneDrive, so far that works, but files are corrupted, doesn't matter the type (pdf, excel file, jpg, etc.).
 
Here is the code.
{

  "type": "OpenApiConnection",

  "inputs": {

    "parameters": {

      "folderPath": "/",

      "name": "@items('Apply_to_each_attachment_from_specific_user')?['name']",

      "body": "@items('Apply_to_each_attachment_from_specific_user')?['contentBytes']"

    },

    "host": {

      "apiId": "/providers/Microsoft.PowerApps/apis/shared_onedriveforbusiness",

      "connection": "shared_onedriveforbusiness",

      "operationId": "CreateFile"

    }

  },

  "runtimeConfiguration": {

    "contentTransfer": {

      "transferMode": "Chunked"

    }

  },

  "metadata": {

    "operationMetadataId": "3c78f01d-b520-47ef-872b-acad8fdcccb6"

  }

}
 
 
Can somebody help me, please.
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,963 Moderator on at
    Hi
     
    Have you looked at the contents of the Files? is it string / 8 / 64 base anything?
     
    I am wondering if you are actually writing the improper contents
  • Suggested answer
    StewC Profile Picture
    120 on at
    I have a flow almost exactly like this. After the On new email action, I test a condition, branch, then on either branch I create a One Drive file.
     
    The one difference is that, inside both of the For Each Attachment loops, I added the Outlook action Get Attachment (v2) immediately before the OneDrive Create file action. Then pull the dynamic values for Name and ContentBytes from the Get Attachment action -- NOT the On Mail trigger action.
     
    Before I added that action, I had the same results as you. Adding this extra action, the attachment saves correctly. I've found this in a few places in Power Automate: the trigger action alone seems like it should provide all the info...but it just doesn't.
     
    Let me know if this works for you.
     
    Stew
     
  • Suggested answer
    trice602 Profile Picture
    16,239 Super User 2026 Season 1 on at
    Hi,
     
    The most likely root cause are the settings in the trigger.  Make sure these are both set to Yes.  I will also share one of the most important things about this flow:  RESUBMITTING test runs will not correctly save your attachment content!!!  I have learned from experience that in order to retest your flows with attachments, you need to send a new email.  That means that maybe your flow is already setup correctly but you are resubmitting previous test runs and finding those attachments are not readable.  
     
     
    Then in the create file action, make sure you point to the contentBytes in your trigger.
     
     
     
    ------------------------------------------------


    If this was helpful, please like and/or mark as a verified answer to help others find this too!


    Always glad to help! 💯💯💯💯💯

    Tom 

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

     

     
  • trice602 Profile Picture
    16,239 Super User 2026 Season 1 on at
    Hey there!
     
    I am following up on this post power automate doesn't save attachments correctly in this category ai builder from 08/23/2024.  I know the post is a little older, but it is a common question here so wanted to take a moment and follow-up. I see there have been 3 replies and 2 likes and asking if your question has been answered.  If so, please help the community out by completing one or more of the following actions!  Thanks in advance!
     
    Easy as 1-2-3 ‼️💯⭐😎🆒🙏
     
    1) Mark a reply as a verified answer - this is essential, and it helps others with the same general question find this thread. ✅
    2) You can also mark one of more replies as a verified answer.  Please take a moment and give the author credit for volunteering their time. ✌️
    3) Like one or more replies.  Kudos always greatly appreciated! 👍
     
    Pro tip:  if you found your own solution or workaround, feel free to add a reply to your own post and mark it as the solution too!  The goal is to get this thread marked with a verified answer by anyone that finds one or more replies helpful!
     
    Again, thanks in advance for reading and responding, always glad to help!  Tom 💯💯💯💯💯
  • trice602 Profile Picture
    16,239 Super User 2026 Season 1 on at
    If I can help with anything else please let me know or tag me in a future post, I enjoy reading and answering questions.  Always glad to help!  Tom 💯💯💯💯💯
  • JV-10071629-0 Profile Picture
    5 on at
    I had this problem and StewC's answer resolved it for me. Thanks Stew!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 816

#2
Valantis Profile Picture

Valantis 603

#3
Haque Profile Picture

Haque 566

Last 30 days Overall leaderboard