Finding the exact text in email outlook body mailbox

Hi all,
How do I try to find the exact match of text that is found in the email body? For example, if I want to try and find if the text “mailbox not found” exist in the body of the email. There are other text that I want to try and find as well such as “No such user here” and “Access denied”. I used for each to iterate in the email outlook to check each email that has a subject saying “Undelivered”. I tried using regex by using the find matching pattern activity in UiPath Studio but when I used log message to check the output in the panel, it is blank even though the text exists in the body of the email.

Email Error1

Please let me know if there is any suitable solution.
Thank you

@Iqbal

you can try with these

boolutput=system.text.regularexpression.regex.ismatch(strinput,“(No such user here)|(mailbox not found)|(Access denied)|(Undelivered)”)

gives you the output as true or fasle

here if above values are to be exact in the mail body

cheers

Hi @Iqbal ,

Do you have a defined set of texts that you would want to check if it is present in the Email Body ?

Also, If you take a look at the Full Expression generated, that is not matching with the text that you would want to Detect i assume.

Maybe a Head start on regex expressions tutorials could be helpful :

Or Provide us with Some Input data Samples and What should be expected output for it, so that we can clear on providing suggestions.

Thank you for this but is it possible if I want the value to be returned as a string instead of a boolean? Because after using regex to find certain text in the mail body, I want to make it able to add the text that is found in a new column in an existing excel file. So below is a sample of the excel that would need to be updated. For example, if the text found using regex is “mailbox not found” then it would update under the column reason as "mailbox not found and if it found “Access denied” then it would update it as that.

@Iqbal

yes it will be done

strvariable=system.text.regularexpression.regex.match(strinput,“(No such user here)|(mailbox not found)|(Access denied)|(Undelivered)”).value

pass this value to an assign and place it in the reason column

cheers

So Iam just trying to find a certain word such as “Email does not exist”, “Access Denied” and so on. I tried to find if such text exists in the body of my outlook email and use regex to try and find it and update it in an existing excel column. Here I have attached the xaml for you to get a better idea. Thank you.
Testing.xaml (18.5 KB)

It worked. Thank you

1 Like

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