How to get value in body mail using uipath


I need to get value in body mail like this


Dear abc,

*This is your ID of customer [value] *


How can I get [value] . pls kindly help


1 Like

Hi ,

  1. Get mail message
  2. Assign mailmessage.body text to a string
  3. Use regex in that string to get the [value] out of that.
1 Like

welcome to uipath community
Once after getting mail body in a string variable named str_body
Then use this expression in a assign activity like this
str_value = System.Text.RegularExpression.Regex.Match(str_body,”(This is your ID of customer).+”).ToString.Trim

This would give us the value part alone

Hope this would help you
Cheers @LucastoH


Hi Palaniyappan,

Because text in mail body alway change so could you tell me how to catch the value i want
I suggest they write CustomerID in [ ] . Can I ?

1 Like

Hi hk803592,

Thanks for help,
but it still workings because text in body include CustomerID change everytime they send to me so i can’t catch that ID.

Any idea to catch that ?

1 Like

Fine in that case we can use this expression
str_value = System.Text.RegularExpression.Regex.Match(str_body,”\[(.*?)\]”).ToString.Trim
If we don’t want the square brackets around
Fine in that case we can use this expression
str_value = System.Text.RegularExpression.Regex.Match(str_body,”\[(.*?)\]”).ToString.Trim.Replace(β€œ[β€œ,””).Replace(β€œ]”,””)

Cheers @LucastoH


@LucastoH Use regular expression

assign str = System.Text.RegularExpression.Regex.Match(str_body,”(?<=[).*(?=])”).ToString

Refer this

1 Like

It’s working , thanks very much !!

1 Like

Cheers @LucastoH

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