How to get value in body mail using uipath

Hi,

I need to get value in body mail like this

ex:

Dear abc,

*This is your ID of customer [value] *

Thanks

How can I get [value] . pls kindly help

Thanks

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

Hi
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

2 Likes

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
Or
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

2 Likes

@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

Great
Cheers @LucastoH

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