How to get access code from outlook mail body

Hello Everyone,

I want to get specific access code from the outlook mail body. The mail body would be like as below.

{Hello RPA Team,

Your access code is: 123456

If you have any questions or did not request this email, please call at 123-456-7890 or email us.}

output required(only access code):- 123456

Please help on this case.

Thanks,
Rahul

Hi @Rahul_G19

Store the mail body in a string variable called Str_Mailbody. Then use the below regular expression to extract the required data.

(?<=Your access code is\:\s)\d+

Create a variable called AccessCode which is string datatype and write the below expression in assign activity.

- Assign -> AccessCode = System.Text.Regularexpressions.Regex.Match(Str_Mailbody.toString, "(?<=Your access code is\:\s)\d+").value

The AccessCode variable will contain the access code in mail body.

Hope it helps!!

1 Like

Thanks @mkankatala,

It works for me.

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