I want to to retrieve a specific keyword from email. Like if I’m receiving an order then I want to retrieve the ordered quantity from email.
How to achieve that?
Hi,
You can use regular expression inside match activity and achieve this.
https://regexr.com/ link to test the regular expression.
Let us know if this helps,
Regards,
Pavan H
Hi @Sameer_Sen,
This can be organizes like below:
It will check each of mail by looking for “your text”. However this is just an easy example. I suggest to check out our https://academy.uipath.com for Level 1 - Foundation Training to see how you can work with these type of projects
Hi
lets say for example you want to extract only numbers from the sentence then you can pass the sentence as string to matches activity and write the regular expression like this to match only the numbers
Expression: abcdefgh4523kajcbdcb4145
pattern: \d
this will give you match only numbers and then output of matchs activity will have IEnumberable of numbers.
Let us know if this helps,
Regards,
Pavan H
Hello,
There’s multiple possibilities for parsing the value.
Is your mail always formatted the same way ? Is it contains tables, texts, links,… ?
Can you provide us an example so we can see which solution best fits your email layout ?
So we’ll provide you the way to use regex expression to parse your value.
Regards.
@Sameer_Sen
The best way to do this is using regular expressions(Refer @pavanh003 post).
For your other query on format,
the email might be sent by multiple people and each person may send in different formats. For you to retrieve the exact data, you should know all possible templates and a key to differentiate each of these templates(This can be the sender’s email ID or any text in the email body). Once you figured the template, you have to write regex to retrieve the data you are interested in. You can write regex to just to retrieve a text value or a table of content. Both are possible.
Hope this helpful!
Hi guys im new to this and im really curious how to get this done.
does anyone have a sample on how to do this?
im trying to get a specific text from an email body.
i.e.
manager - edward
this can be found in the body of an email anywhere. the name can change but the constant word is manager.
how do i get the name using manager as the constant?
- Store body of the mail in a string variable say ‘getText’. Then try below expression to fetch name.
getText.Substring(getText.IndexOf("manager - ")+"manager - ".Length).Split(Environment.NewLine.ToCharArray)(0)
You are awesome Sir @lakshman … that worked…
Although the result did give me spaces before the text… ill figure out how to get rid of it…
To remove spaces before text - StringName.TrimStart
To remove spaces after text - StringName.TrimEnd
To remove spaces before or after or in between text - StringName.Trim
Awesome!!! i actually did the edits on excel as im used to that but this helped me with getting rid of that extra step.
Thanks
@lakshman
I am facing this run time error using your solution i.e. getText.Substring(getText.IndexOf("manager - ")+"manager - ".Length).Split(Environment.NewLine.ToCharArray)(0)
Please help me with this.
Can you please tell me , how to get email body in plain text using the Get IMAP mail message activity .
-
Get IMAP mail message will give you output as List of mail Messages.
-
Then use For Each loop Activity to itreate that list.
ForEach item in mailMessages
Print item.Body.Tostring to display
body of the mail.