Read mail which contains the specific keyword

i have requirement to process the mail for automation ,which the mail body contains the specific keyword like “AB1234567”,“AB123”,“AB1234”.Need help on this,Thanks in advance.

Hi @sreedharmasula,

Inside the iteration of ‘for each loop’ for each mail, use an ‘if activity’ with condition mail.Body.Contains("AB1234567") or mail.Body.Contains("AB123") or mail.Body.Contains("AB1234")

Warm regards,
Nimin

Hi Nimin,
Thanks for the reply,here AB is fixed but after AB it may change not exactly 1234567 .

Hi @sreedharmasula,

You could use @nimin’s solution with a variable like this:
“id” could be “1234567”,“123”,“1234”

 Str1 = "AB" + id
 mail.Body.Contains(Str1)

Regards,
PD

1 Like

Hi @sreedharmasula,

You can simply use the condition mail.Body.Contains("AB") in the ‘if’ activity to get all mails contains "*AB*" in the mail body. If you want to get only the string AB followed by some numbers(AB3123), you can use the condition System.Text.RegularExpressions.Regex.Match(mail.Body,"AB\d+").Success

Warm regards,
Nimin

Thanks nimin,
It is working fine for me ,But i have another problem with mail signature,After fetching the “AB3456” keyword ,i need to read the next two lines of content followed by “AB3456”.But from these two lines if second line has no content mail signature is appearing as second line,is there any way to avoid the mail signature or how can i handle this situation .

Hi @sreedharmasula,

Sorry, I am unable to understand your exact requirement. Could you please provide with a sample input and desired output?

Regards,
Nimin

in the process of mail automation ,we don’t want to read the mail signature.how can we do this please help me on this