Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

Corrupt PDF when sending as Gmail Attachment

(Before I explain, please note I've read about 5-10 other threads here on this forum about corrupt PDF attachments and none of the "solved" answers were really solutions. I've been at this for 6 hours now and am losing my mind.)

I have an online form that customers use to purchase ebooks. Flow starts when the form is submitted, and it's supposed to send purchased ebooks as email attachments via Gmail.


How the flow basically works:

  1. Get the ebooks from Google Drive using "Get file contents from path" -- works
  2. Get file names and types from Google Drive using "Get file metadata from path" -- works
  3. Append to array variable: -- works I guess
    "Name": "body('Get_file_metadata_using_path')?['Name']",
    "ContentBytes": "body('Get_file_content_using_path')",
    "ContentType": "body('Get_file_metadata_using_path')?['MediaType']"
  4. Send email with attachments. The array variable is added in the Attachments field.


Now, the email does get sent and the files do get attached - file sizes and names are okay.

BUT, the files are corrupted, I can't open or preview them.

I've tried so many things ... not using the array variable and just sending the files as is (adding the "File Content" dynamic content in the attachment field), tried using base64() conversion, base64toBinary(), just binary(), all possible conversions - I don't even know what these do. I tried changing filenames, tried declaring values with or without quotation marks, tried sending the email via SendGrid instead of Gmail, I just don't know what else to do and this thing is utterly broken. 




Screenshots: -- Flow -- Corrupted PDF -- Corrupted PDF


Accepted Solutions

Does this happen with any PDF? Or only with larger PDFs?

View solution in original post


Does this happen with any PDF? Or only with larger PDFs?

View solution in original post

Thank you!!

I didn't even think of file size because I was testing with 2-3 relatively small files (less than 2MB each) - but it looks like there's a limitation of around 5MB. 


I removed the Gmail connector and used SMTP instead - it works!

Helpful resources

2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,059)