Text Parser - specific email

I want to extract a single email address from an email body.

It’s not the sender, it’s in the body of the text. It’s not in the same line each time, but it does always follow a specific piece of text.

Following the text “Original-Recipient: rfc822”, I want to extract the 1st email address after that (email #3, see screenshot).
How best to go about that?

2024-03-30 19_06_48-#4004 Undelivered Mail Returned to Sender - no-reply@sendgrid.net

Welcome to the Make community!

When reaching out for assistance with your regex pattern for a Text Parser module, it would be super helpful if you could share the actual text you’re trying to match. Screenshots of text can be a bit tricky, so if you could copy and paste the text directly here, that would be awesome! It ensures we can run it against test patterns effectively. If there’s any sensitive info, feel free to change it to something fictional yet still valid by keeping the format intact.

Providing clear text examples saves time on both ends and helps us give you the best possible solution. Without proper examples, we might end up playing a guessing game, and nobody wants that as it is a waste of time! You are more likely to get a correct answer faster. So, help us help you by sharing those text snippets. Thanks a bunch!

2 Likes

Thanks for the guidance.
Here’s the text with emails changed:

This is an automatically generated message from SendGrid.

We are sorry to tell you that your email was unable to be
delivered to one of its intended recipients.

If you require assistance with this, please contact SendGrid support.

Access denied - .102 listed by multiple RBL providers at the same time.

X-SendGrid-Sender: Paul Read paul@mydomain.com
Arrival-Date: Wed, 27 Mar 2024 18:26:16 +0000

Final-Recipient: rfc822; mickey@somedomain.com
Original-Recipient: rfc822; mickey@somedomain.com
Action: failed
Status: 159.183.224
Diagnostic-Code: 550 Access denied - 159.183.224.102 listed by multiple RBL providers at the same time.

Welcome to the Make community!

Screenshot_2024-02-20_151445

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

Original-Recipient: [^;]+; (?<email>[^\n]+)

Proof

https://regex101.com/r/xrQ9Jn

Important Info

  • :warning: Global match must be set to NO!

Screenshot

Output


For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!

3 Likes