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 / How to use ContentByte...
Power Automate
Answered

How to use ContentBytes from email attachment

(2) ShareShare
ReportReport
Posted on by 149

My cloud flow looks like this. 

vkama_0-1692186954040.png

The problem is that i want to pass the base64 string from a pdf attachment to my desktop flow. As you can see, the Get Attachment actions produce a variable of content bytes that contains a string. 

vkama_1-1692187207951.png

When i try to pass this string into a variable it seems that the previous string is converted to something like this 

vkama_2-1692187292557.png

So, how can i pass the first string into my desktop flow in order to create the file with the action "Base64 string to file" ?

 

Categories:
I have the same question (0)
  • Verified answer
    Matthy79 Profile Picture
    4,188 Super User 2024 Season 1 on at

    A really annoying bug. I created a ticket for this but it's always hard to pass the first level. But you use it a little different than me, so I'm not 100% sure.

     

    Have you tried to "convert" it to string. I know. It is already a string, but Microsoft sometimes tries to do things they shouldn't do. So just try "string(contentBytes)" (instread of contentBytes you have to use the whole path to the contentBytes of course). You could also try "base64(base64ToBinary(contentBytes))".

     

    Both solutions lead to another bug because you won't see this formula (except peek code) if you don't use it in a compose action. Microsoft knows about this and documented the issue 😄

  • vkama Profile Picture
    149 on at

    Thanks for the help! 

     

    I already tried the string() expression and the problem is still there. The strange thing about this problem is that when i resubmit the failed flow, ContentBytes is not changing its value and the flow runs without an error. 

     

    I'm going to try "base64(base64ToBinary(contentBytes))" and i will give u an update. 

  • Matthy79 Profile Picture
    4,188 Super User 2024 Season 1 on at

    I know about the resubmit thing and I have a ticket open at Microsoft for this issue.

     

    About the string() function. What is the value in the flow run history if you use it? Could you please post that part of the flow and the expression you are using?

  • vkama Profile Picture
    149 on at

    Now i have changed the flow and i can't find the exact run that has the string expression. 

    It was like the flow that i posted but in the "Set Base64file" action i had string(ContentBytes) that was produced from get attachment action. 

    The result was the same as the third screenshot that i uploaded. 

  • vkama Profile Picture
    149 on at

    I used the function "base64(base64ToBinary(contentBytes))", as @Matthy79 said and the flow FINALLY worked! 

    Thanks a lot @Matthy79 !

     

    BTW for some reason the value is not showing as the result of the function but only as the output of compose. 

    flow.png

  • rahullakshmanan Profile Picture
    30 on at

    I got the same issue and your solution worked, not sure why this bug is not fixed yet

  • BrettParkhurst Profile Picture
    2 on at

    I worked and worked on this and @Matthy79 solution worked!!!

     

    base64(base64ToBinary(contentBytes))

  • tylercat Profile Picture
    3 on at

    i worked on this for a few days. what a mess. thank you so much for finding a solution that works!

     

    Just to be clear for those looking for a solution, you need to:

    1. Compose a string that contains 'content bytes'

    2. Compose another string that converts the first string from base64 from base64tobinary. Image attached.Screenshot 2024-04-27 at 8.20.47 AM.png

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard