Skip to main content
Hey friends! This week I’m going to talk about how to create a Zap that will take PDF attachments received in Gmail and upload them into the relevant client folder in Google Drive. This guide specifically talks about how to to this with Gmail and Google Drive, but you can apply the same principles to other similar apps too!
 
We’ll cover how to take specific PDF file attachments, create a new folder (if one doesn’t already exist) for them in Google Drive, upload the file to that folder. We’ll also get the Zap to send out an email to the client thanking them for sending us the file.
 

You can download a copy of the Zap template for this workflow here:
Upload PDFs into client's Google Drive folder and send email autoresponder

Setting up the trigger

First up we’ll need to set up the trigger that runs when a new attachment is received in Gmail. To do that we’ll want to select the New Attachment trigger for Gmail. This will trigger the Zap separately for each attachment added to an email.
 
In the Search String section you’ll want to set up a relevant query to ensure your Zap is only triggering for the right types of emails. For example if I only wanted to trigger for new emails in my inbox emails with the subject line “artwork” then I’d set it up like so:
6ab3929f1205f6b7d12a941090967b8d.png

💡 TIP: Make sure you specify the mailbox for the Label/Mailbox field. I say this as the Sent items folder will also be checked by the trigger step and we won’t want to create an accidental Zap Loop when we send out the auto responder email to the customer later on!

Setting up a Filter

As I’m only wanting to upload PDFs I’m going to add a Filter step use the condition (Text) Contains pdf to ensure that only an attachment with a Mime Type of application/pdf will be uploaded:
a2bc80061c9ef213b839ca679e02ffc1.png

Extracting the client name

Now that the Filter is added, let’s keep things super organised by creating a new folder specific to this client (if there isn’t one for them already!). But wait, how do we know what client it is from the email? 
 
Well in most cases the client name is the same as their email domain name so you can use a Formatter (Text > Extract Pattern) step to extract the domain name. You can learn more about using Regex to find and extract text here: Find text with regular expressions in Zaps

If you’re not familiar with Regex that’s ok, you’ll just need to add @(\w+) to the Pattern field to extract the word (domain) that appears right after the @ symbol:
cc52823a1b676666ebd93b830e2d85fa.png
When we test the step it would then output the word “zapier”. So regardless of what the client's email address is or whether it ends in .com, .org, .uk etc we should be able to always extract the domain name from it. Cool right? 

Find/create the folder

Next, you’ll add a Find a Folder action for Google Drive and select the output from the previous formatter step for the Folder Name field. Choose the relevant Drive and Parent Folder as necessary: 
1135fe7e7ee0e472d12a1e2f6512f0d0.png
Note that under the Parent Folder field, there’s the option to Create Google Drive Folder if it doesn’t exist yet?. You’ll want to make sure that’s selected so that the Zap can automatically add a new folder!

Upload the File

Now let’s add an Upload File action and choose the Custom value option on the Folder field. Select the ID number for the folder that was found/created by the previous step.
51868008047cf0554c3bad8e73f5f6ac.png
Next, select the Attachment field from the Gmail trigger step that contains the file: 
659cf547e7fd5a312a1808f710568042.pngTest the step to ensure that will upload the file correctly. I’d also recommend heading over to Google Drive to make sure it definitely worked as expected:
e6fb1c1204dca3086439744d8389a14d.pngYay, it worked! 🎉

Set up an autoresponder email

Now, our clients will want us to let them know that we got their really important file, but we’re super busy and don’t have time to respond to every email. So let’s send them an automated email to say thanks and let them know that we’re on it.
 
To do that we’ll use Gmail’s Send Email action and select the clients email address and name from the Gmail trigger step. In the From field select the email address or alias you want the email to be sent from. Set a From Name and add the message for the email into the Body field:
213c35f77f695ab822667786b4c4ebd9.png
In the above example, I’ve chosen to sent the email as Plain text. But if you select html for the Body Type field you can then include HTML tags in your message. But it’s important to note that not all tags are supported. 

You can find out more about the HTML tags that Gmail supports here: What HTML tags are supported in Gmail?
💡TIP: If you’ve got any VIP clients you’d prefer to send out a more personalised email response to manually, a Filter step can be used to check that the sender of the email doesn’t contain their email address. 
 
And if you want to get really fancy, you could use Paths to add some conditional logic to your Zap to carry out different actions based on whether the client is a VIP or not. For example if the sender is a VIP you could get the Zap to send you an urgent SMS to let you know that a VIP client needs a response ASAP.
 

Wrapping up

If you made it this far, thanks for reading! Don’t stop at just organising uploads into client specific folders and sending out an email? You could add in a Send Direct Message Slack action to alert you when a new file has been uploaded. Or you could create a client-specific Google Sheet spreadsheet instead and add a new spreadsheet row to log details from the email so you can keep a record of everything that’s been received. The possibilities are endless!
 
I do hope you find this useful and that it inspires you to create lots more time-saving Zaps. 

Happy Zapping! ⚡️

Hi 

Thanks for this info it has been useful. 

im trying to make it so that when an email with multiple attachments of different file types is received only the pdf attachment is uploaded to Drive, but I’ve not managed to make it work.  

 any tips gratefully received. 

 

thanks

ed

 


Thanks! Is it possible to upload only few pages of the pdf and not the whole pdf?


Hi @Ed AGR and @KD2520! 👋

@Ed AGR - I’m so sorry to have missed your message here previously! Were you since able to get it resolved? If not, can you share some screenshots (please remove/hide any private information like names, emails etc) showing the set up of any actions in the Zap that aren’t working as expected as I’ll be happy to assist further! 

@KD2520 - I’ve not used it but I know that the PDF4me app on Zapier has an Extract Pages From PDF action. Perhaps you could use that to extract the desired pages from the PDF and upload them? You can see a full list of all the document related apps on Zapier here: https://zapier.com/apps/categories/documents

Hope that helps! 🙂 


Hi, no I did not manage to resolve this but found a free way to do it, as I did with other automations I wanted. This zap got stuck in a loop, despite me pausing it, uploaded the same file several hundred times and ate all my credit. 

 

In the end I cancelled my Zapier account at renewal as it was not working for me. 

 

thanks

ed

  


Really sorry to hear that @Ed AGR, but totally understand. If you ever change your mind and want to give Zapier another try, please do reach out to us in the Community again if you run into any issues or questions and we’ll be happy to help! 

For anyone that comes across this thread and is also running into a Zap loop: please check out our Zap is stuck in a loop guide which has some advice on how to avoid Zap loops. And if you’ve had any unexpected task usage due to an accidental Zap loop please get in touch with our Support team here who will be happy to assist further. 🙂


Hi, thank you for this!

I tried it and managed to extract one file from my email to G-Drive. But what if you would like to add all files in the Email to the Drive? I seem to only be able to add one. Any tipps?

Many thanks

Sylvia


Hi @Fairdoc 👋

The New Attachment trigger for Gmail would run for each email attachment separately, so when testing in the Zap editor it’s expected that only a single file would be added to Google Drive. Only when the Zap is switched on would all email attachments be added. For example, if you receive an email with three pdfs, each PDF would trigger the Zap separately and would either find or create a new folder and upload the pdf into it. Which would result in all three pdf files being added into the same folder.

Hope that helps to clarify 🙂


Ah, that’s great! Thank you for clarifying!


You’re most welcome @Fairdoc. 🤗 Do let us know if you run into any trouble with it once it’s running live–happy to help further!


I cannot fin a way to only updload the pdf. 

 

I use another trigger which is new email and filter attachment count is different than 0. 

 

But I cannot filter to “only” get the pdf files. 

 

is there a way?


Hi @Andrea Ferradans 👋

In order to filter on the individual attachments you’d need to use the New Attachment trigger instead of the New Email trigger. The New Attachment trigger would be triggered separately for each attachment which allows the Filter to check the Attachment Details Mime Type field (of the specific file that triggered the Zap) matches application/pdf which would indicate that it’s a PDF file triggering the Zap. 

Can you try switching to the New Attachment trigger instead and let us know whether that helps to get the Zap uploading PDFs only?


Reply