Sending a PDF file as an email attachment with Power Automate corrupts attachment

Copper Contributor

I have followed this great tutorial for creating and sending digital certificates to event participants (https://techcommunity.microsoft.com/t5/educator-developer-blog/send-digital-certificate-to-event-par...), and everything worked except for the last step which is sending the email with the certificate attached. I am able to receive an email with the pdf attached however, the file is corrupted and I'm unable to open it. When I check the pdf file in my share point it is not corrupted so the issue seems to be in the step of sending the email.

I tried using base64ToBinary(base64(body('Convert_file'))), when I added this I was able to open the pdf attachment but the pdf was empty and the content was erased. Please let me know if there is any way to overcome this issue. 

13 Replies
The issue was resolved on its own by using the old flow editor instead of the new designer.

@Bayan000 I switched to the classic editor, but it didn't work for me :(

@Bayan000 I am having this exact issue. Did you find a solution?

@punkymatta The issue is that in the new designer, when using send email V2, it does not grab file name and file content in the same manner as the old one.  If you delete or modify your attachment section using the old designer, you will see that your options on getting the data from the one drive connector are different and once applied, your code should work.

@Bayan000 I can confirm switching back to old designer fixes this issue (as of 12/17/2023).

This should work like a charm

 

base64ToBinary(outputs('GET_FILE_CONTENT')?['body']?['$content'])
 



@Bayan000 

This was exactly what I needed to fix my problem! Thanks for sharing this.
I found the solution here - using the old designer! This bug was driving me nuts. I knew the input was wrong - but as you cannot change the code i could not fix it.

@Bayan000 I am still having this issue can you share your flow?

@daisysx1987 you will add it to your 'Compose' portion of your automation.  The bigger thing you'll need to make sure (unless they've fixed this bug, haven't had any issues as of late) is to make sure you are not using the new designer mode as for some reason it populates item's slightly different and corrupts the file once created.

Hope this helps

 

Were you referring to adding this code to the 'Compose' portion. I tried to find that section of the automation in the 'peek code' settings in the Send V2 email but didn't see where 'Compose' was located. Can you elaborate please?

base64ToBinary(outputs('GET_FILE_CONTENT')?['body']?['$content'])

@Bayan000 , Hi. I am using my organization's web based version of Power Automate which does not have an option for reverting to the old designer. Is there a fix for those of us stuck in the new designer? Thank you very much.