Sending PDF in Gmail Attachment

Hello,

I saw similar questions to mine but still could not reach an answer. I want to send a couple PDF attachments in my email but am not sure how to do so.

I’m assuming I need to upload the files to a google drive and then download and attach them but where would they fit in my work flow?

Hi @Bryan_K,

If the PDFs are hosted already (just click and download), then you can just include a link to them in the body of the message.

If you want to attach them to the email, you need to download the raw data of the PDF first.
You can do this with an HTTP Get a File module.

With Gmail following HTTP Get a file, you have the change to map a File to the HTTP module, or select the Map option which allows you to select the Data and Filename separately (in case you wanted to alter the file name instead of using whatever the original file name is).

image

If you need to attach multiples, then you would need to set an Array Aggregator before the Gmail module. The Array Aggregator aggregates the results of the HTTP Get a File, then you select “Create a Draft: Attachments” as the Target Structure Type from the Gmail module (GMail module must be connected after the Array Aggregator for this option to show up).

image

Hope that helps!

Edit: HTTP Get a File might not work for you if you’re downloading PDFs from a protected source. In that case you’d need to use another module to get the PDF in data/buffer form.

4 Likes

Hey Donald,

First of all, really appreciate the detailed response! Definitely helped a lot.

I took what you wrote and changed it a little so that I am downloading files from a google drive as opposed to using the HTTP module. I also attached an array aggregator but for some reason, only 1 PDF attachment is being sent. Do you see anything obviously wrong with my flow?

I want to say that it’s because my gdrive file ID is choosing only 1 file but I can’t seem to keep it open. Below is a ss of my aggregator in case that is the issue. Thanks!!

My guess is that “ Download a File” is only getting a single file.

Aggregator is still working but only has one file to work with.

Assuming you need multiple PDFs from a Google drive folder, Try using a Google Drive Search for Files on a folder, that should output multiple bundles. Follow that with a Download a File module, which should download each. Follow that with an Array Aggregator and set the source as the Search for Files module.

2 Likes

Hey Donald, unfortunately that still doesn’t work because the File ID in “download a file” only lets me pick 1 file.

Any tips?

You will need to supply the File ID dynamically because it will run multiple times. You can get the File ID from a Search for Files module.

3 Likes

Gotcha makes sense!

I guess the final step is how do I get the loop to run again so that I can have multiple downloads so that I can aggregate them into an array? Really appreciate your prompt responses!

It depends, what is the source of the files? How do you know where each file is? I assumed they would both be in a single Google Drive folder, which you would be able to search. If that’s not the case, you have to take a different approach.

2 Likes

Yup they are all in a single gdrive folder (there are 3 attachments). I think I didn’t explain myself clearly.

If you look at my workflow below, I want to send all 3 attachments in 1 email but this flow makes me send 3 emails (each with 1 attachment).

You may remove your Iterator #26, then set #23 as the source of the Aggregator. #23 is acting as your iterator here.

1 Like

My man!!! You are hero!

Can’t tell you how much I appreciate your help.

2 Likes