cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ines
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. 

 

Help!

 

Screenshots:

https://ibb.co/dk64U9 -- Flow

https://ibb.co/m6sNGp -- Corrupted PDF
https://ibb.co/hZSB99 -- Corrupted PDF

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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

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

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,053)