Best answer

Get specific url from an email

  • 10 May 2020
  • 7 replies

Userlevel 1

I want to set up a Zap that extracts a URL from an email, downloads the pdf (from the public URL), and uploads it to Google Drive.

The problem is that there are multiple URLs in the email body so I can't use the Extract URL option. I was thinking I could use the Extract Pattern first to find the text that belongs to the URL.

So my Zap would be:
- Email matching search
- Extract pattern from email body
- Extract URL from the pattern
- Download pdf from URL & upload it to Google Drive.

In the email, there's a text link: "Click here to download a PDF of this order (URL)"
In Zapier, I've selected Customize Text and Extract Pattern. However, I have no idea how I need to define the pattern in Zapier. Can anyone help me with this?


Best answer by Celine 11 May 2020, 13:00

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

7 replies

Userlevel 7
Badge +9

Hey! There could be quite a few ways to do this. I think you’re on the right track. Would you be able to share an excerpt so we can perhaps suggest the best way to do this?

Userlevel 1


The email is an order notification from my online store, I get them to notify me when someone has made a purchase. These emails have a link to download the invoice (adding them as an attachment isn’t possible) and that’s the URL I’m trying to extract. There’s more than one URL in the email, so the Extract URL option from Zapier isn’t possible here. 
(I hope this helps, sharing more info on a public forum is a bit difficult)

So the text Zapier needs to look for in Body Plain:

Click here to download a PDF of this order (url)

Do you know how I could set up the pattern to look for this piece of text (with an URL that will be different for each email)? I tried looking at the Python Regular Expression instructions, but I’m not familiar with coding, so I couldn’t make it work.


Userlevel 7
Badge +9

:joy:  I need to see the pattern or the potential variants of the pattern before I can help, I think. 

In particular - What do all the URLs have in common/what’s different about them? 

Is there anything that’s always the same about the one you want to extract?

Userlevel 1

:joy: Got it, sorry :see_no_evil:  

The first part of the URL is always the same:

After that it’s a series of numbers of letters and numbers for the specific order, so that’s different for every URL.


Userlevel 7
Badge +9

That series of numbers/letters you’ve left out will still be important, too - As will the other URLs :grin: - The reason it’s important, is because there will normally be a set pattern

All of this info is important, in fact - I think you’ve shared the least important part...But let me try to make a suggestion based on what you have shared with me: 

So if we break it down - We can see that we have a domain “storename” and we also have a path “download-pdf”, if these two things are unique, we could write a script to look for these elements, and only extract if these two things match our requirements. 

Userlevel 1

I played around with a few settings and found another way to extract the URL. 

Instead of having to write a script for Extract Pattern, I used Split Text.

So now the Zap goes:

  • Email matching search
  • Split Text email body (just before the specific URL I need)
  • Extract URL from the split text
  • Download pdf from URL & upload it to Google Drive.

@Saastronomical  Thanks for your help! 

Userlevel 7
Badge +9

Amazing! Glad to have helped (even if, I didn’t really help that much) :joy: