Regex for Mail Address

Hi.

One workflow sends mail with body to another like this:

MailAddress: some.one@company.com
NextTopic:

The second workflow receives the mail address in the mail body as hyperlink.
It gets wrong data out of received mail when using this regex:

“(?<=MailAddress: )([\S\s]*?)(?=NextTopic:)”

Any suggestions?
Thx. KR, Vanja

Hi @VanjaV

Can you try this

emailAddress = System.Text.RegularExpressions.Regex.Match(mailBody, "(?<=MailAddress: )([^\s<>]+?@[^\s<>]+)(?=\s*NextTopic:)").Value

Regards,

Hi @VanjaV ,

Could you let us know what is the expression that you have used to extract the value using regex ? Is it the activity or the Regex.Match() method ?

Also, the other data getting extracted, does it have any resemblance to the email format ?

Hi, I am using this activity:

String data get extracted OK with regex like this.

Hi @VanjaV

Try this expression in assign activity

System.Text.RegularExpressions.Regex.Match("yourstring","[A-Za-z.\\d-]*@[A-Za-z\\d.-1*$]*$").ToString.Trim

Regards,
Gowtham K

@VanjaV

(?<=MailAddress: )([^\s<>]+?@[^\s<>]+)(?=\s*NextTopic:)

The image shows the properties panel for a UiPath activity called "Find Matching Patterns," detailing settings for input, misc, and output parameters. (Captioned by AI)

Regards,

Yes, it works if you read it from the string.
But it does not work if you read it from a mail with hyperlink.

My regex now returns:
image

I will do a second regex out of it.

Thx for all advices.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.