Unable to extract data from email body to excel

I have multiple emails from which I need to extract specific data into excel.I tried doing this but I am getting blank data in excel.

This is body of email
Hi,

Download Person Name:
Uzair mr

Download Person Email:
uzli@gmail.com
Download Person Phone
ES +9178442354

From this body I need to extract Person Name,Email and Phone.
Could you please help me in doing this.

@waseem Can you Try this Expression :

Name = System.Text.RegularExpressions.Regex.Match(mail.Body,“(?<=Download Person Name:\n).*”).Value

Email = System.Text.RegularExpressions.Regex.Match(mail.Body,“(?<=Download Person Email:\n).*”).Value

Phone = System.Text.RegularExpressions.Regex.Match(mail.Body,“(?<=Download Person Phone\n).*”).Value

1 Like

@supermanPunch I tried using the above expression as well as this expression :
System.Text.RegularExpressions.Regex.Match(Mail.Body.ToString,“(?<=Person Name:\n)\w+\s(\w+)?”).ToString.Trim
still I am getting a null value for both.

@waseem Doesn’t your Mail Body contain the word Download Before Person :sweat_smile: , Even though you have excluded the Download Word, you should get the Output.

@waseem Are you sure the mail that you get is in the right format ? Can you check the Mail Body using a Message Box ?

@waseem Ok. I think i was able to get the Output. But It is Strange that only if i add a return carriage I am able to Extract the Values. I have added a \r to the Expression. Please Check if it works on your side, Also if the real purpose is to extract the Data from the mails directly, I suggest you to check the same and revert back if it doesn’t work.
Markat_Mails.zip (24.8 KB)

2 Likes

@supermanPunch Thanks for the solution but It works fine only if I use Outlook but when I use Gmail its giving null value .
Actually in Gmail it is fetching the entire body as null.

@waseem Then that would be a Problem in the Mail Activity i suppose, The Mail Body is not present ?

Its working now…Thanks a lot @supermanPunch

1 Like

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