cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Multiple attachments array is corrupting image file

Hi everyone,

 

I am trying to create a flow with an array of an attachments and I have followed some of the other articles on here to get help however none of them seem to be resolving my issue.

 

In the flow, I get the attachments from my original email, and then reattach a few of these to another email later in the flow.

 

When I test using the attachments section of the 'Send an email v2', this sends my image file with no issues and I can open it on the other end (seen below)

 

chloelawr_0-1606470600237.png

 

However when I use the same code to append my image to an array variable, my image file is corrupt on the other end and looks something like this:

chloelawr_1-1606470733637.png

 

I have added images of the full flow below. I would really appreciate if someone can identify where I'm going wrong! 🙂 Thank you 

 

chloelawr_2-1606470824022.png

chloelawr_3-1606470840442.png

chloelawr_4-1606470861314.png

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@chloelawr  @Expiscornovus 

You shouldn't to wrap in base64() as the 'Content Bytes' property in the array should accept a full file contents schema... the base64() expression would just write in the $content value... which can cause issues in arrays.

@chloelawr - if you are trying to add the output from the Encodian action to the array then you need to wrap the Encodian 'File Contents' property in the base64ToBinrary() expression when writing the value into the array variable...

I know this seems odd as the Encodian 'File Contents' is already just as a Base64 string... but, Power Automate will silently re-encode the base64 value and thus you'll get a corrupt output. By wrapping in the base64ToBinary() you are informing PA that this is a file and do not re-encode.

Check out this video which explains this in detail: Add multiple attachments to an email in Power Automate

HTH

Jay

View solution in original post

New Member

@Expiscornovus thanks but sadly this didn't work and I got the same issue.. although it was close 🙂 

 

@Jay-Encodian it isn't actually the encodian image I am trying to attach, I am just using the encodian image resizer so my AI Logo detector model actually works as the file size was too small before.
However, I used base64tobinary as you advised with the dynamic content I needed and this has worked! Thanks very much 

View solution in original post

6 REPLIES 6
Super User II
Super User II

Hi @chloelawr,

 

Can you try and apply the base64 function to your ContentBytes when appending it in your array variable?

https://sergeluca.wordpress.com/2019/08/15/dynamically-create-a-list-of-e-mail-attachments-with-micr...

 

Let me know if that works.

 

With kind regards,

Dennis

@chloelawr  @Expiscornovus 

You shouldn't to wrap in base64() as the 'Content Bytes' property in the array should accept a full file contents schema... the base64() expression would just write in the $content value... which can cause issues in arrays.

@chloelawr - if you are trying to add the output from the Encodian action to the array then you need to wrap the Encodian 'File Contents' property in the base64ToBinrary() expression when writing the value into the array variable...

I know this seems odd as the Encodian 'File Contents' is already just as a Base64 string... but, Power Automate will silently re-encode the base64 value and thus you'll get a corrupt output. By wrapping in the base64ToBinary() you are informing PA that this is a file and do not re-encode.

Check out this video which explains this in detail: Add multiple attachments to an email in Power Automate

HTH

Jay

View solution in original post

New Member

@Expiscornovus thanks but sadly this didn't work and I got the same issue.. although it was close 🙂 

 

@Jay-Encodian it isn't actually the encodian image I am trying to attach, I am just using the encodian image resizer so my AI Logo detector model actually works as the file size was too small before.
However, I used base64tobinary as you advised with the dynamic content I needed and this has worked! Thanks very much 

View solution in original post

Hi @chloelawr Good news 🙂

Basically, if the value you are writing into the array variable is just a base64 string then it needs to be wrapped in the base64ToBinary() expression otherwise PA will silently re-encode the base64() again! The difficulty is you can't see this change in the run history.

Thanks @Jay-Encodian.. understood! I was trying with so many different scenarios so I'm glad I gave up in the end and came to ask the community.. I would have never got it otherwise 😀

Super User II
Super User II

Thanks @Jay-Encodian, I wasn't aware it silently re-encodes it and you have to use the base64ToBinary() expression. Good to know 🙂

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (28,253)