How to get a specific text from email body

Hi, I am new to UiPath and have been trying to read mails and extract email id mentioned in the body of each email. I got through extracting data of mail body but i couldnt get the email ids from it.

For eg,
Below is a sample mail

Hi Raj,
Please mail the loan documents sundar123@gmail.com for final processing.
Send it to krishnanGopal@outlook.com to get it approved
For further queries, reach out ITMPServices@live.com
Thanks.

In the above mail content, I need to get the email ids which are mentioned in the body and store it in a data table. Kindly help.

1 Like

@harishk5

Use below regular expression to get Gmail id from body of the mail.

(\W|^)[\w.+-]*@gmail.com(\W|$)

Hi @harishk5,

Welcome buddy to UiPath Community…! Thats a good question to start with…!

Kindly find the below xaml for your reference, hope this would help you…!

Harish.zip (1.9 KB)

Cheers…!

1 Like

Thank you Lakshman for giving an idea, but the email ids present in the mail body wont follow same format like ‘.test’ and also the domains change. To be precise, i want to get any type of email address that are present in the mail body and the only common thing is ‘@’ symbol and ‘.com’ text.

@harishk5

Try below regular expression:

^\w+([-+.']\w+)@\w+([-.]\w+).\w+([-.]\w+)*$

Hi @harishk5,

If you see in the text the email has a prefix as “to” and the email ends with “for” and this pattern will be followed in all the mails i think

If yes, then use the below regex, which extract all the emai id’s

(?<=to )(.+)(?= for)

Hello@harishk5,
Use Matches Activity in user sequence and click on configure regular expression

then you get a window in that select regex as email like shown in image image , give input as your email body and for each out put variable to get the mails or else use ([\w.-]+)@([\w.-]+).([a-zA-Z]+) reqular expression in matches activity do the same. image

3 Likes

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