Skip to main content
Best answer

How to extract email addresses from purchase confirmation emails?

  • September 5, 2021
  • 4 replies
  • 229 views

Dear Zapier Community!

I’ve been searching for this in our Community but have not found, and I need your help!

  1. I receive automatic payment confirmation each time when a customer buys my product.
  2. Payment confirmation has a customer’s E-mail that inside the content of confirmation E-mail. Customer’s E-mail is already registered on the list in Active Campaign.
  3. I want zap that triggers when purchase confirmation E-mail lands in the box, searches for customer’s E-mail inside purchase confirmation E-mail content and add specific tag to the same E-mail in Active Campaign.


This is going to save a lot of my time and improve customer’s experience.

 

Best answer by SamB

I just came across this and wanted to confirm that the Formatter (Text > Extract Pattern) that Troy mentioned has the ability to return multiple email addresses.

To achieve that you’d need to set the Match All field to Yes:

3ce0831a5bab185c8b2a7e85fd8ddbb2.png

The pattern you’d use to extract the email addresses (see How to Extract Email Addresses, Phone Numbers, and Links From Text) is as follows:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Provided the email addresses only use standard English characters the pattern above should work for all standard email addresses, sub-domains, and TLDs. :)

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

4 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • September 5, 2021

Hi @Przemysław 

Try using the Formatter > Text > Extract Email action step: https://zapier.com/help/create/format/extract-data-in-zaps#extract-email-address


  • Author
  • Beginner
  • November 8, 2021

Ok this works but limited only to the first E-mail from text filed. What if I want to extract another E-mail from the same field?


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • November 8, 2021

@Przemysław 

Try using the Formatter > Text > Extract Pattern action step: https://zapier.com/help/create/format/find-text-with-regular-expressions-in-zaps

Or you can use a Code step: https://zapier.com/apps/code/help


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • Answer
  • December 15, 2021

I just came across this and wanted to confirm that the Formatter (Text > Extract Pattern) that Troy mentioned has the ability to return multiple email addresses.

To achieve that you’d need to set the Match All field to Yes:

3ce0831a5bab185c8b2a7e85fd8ddbb2.png

The pattern you’d use to extract the email addresses (see How to Extract Email Addresses, Phone Numbers, and Links From Text) is as follows:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Provided the email addresses only use standard English characters the pattern above should work for all standard email addresses, sub-domains, and TLDs. :)