I want to extract the verification code from mail body. Mail body mention in description. Each time code is different

Below is the mail body format

You recently logged in to Salesforce from a browser or app that we don’t recognize.

Browser: Edge

Operating System: Windows 10

To ensure your account’s security, we need to verify your identity. Enter the following code where prompted by Salesforce.

Verification Code: 602062

If you didn’t recently log in to Salesforce, or you don’t recognize this browser or operating system, contact your Salesforce administrator.

Hi @Puneet_Singh

Can you try this,

str = “Verification Code: 602062”

verificationCode = System.Text.RegularExpressions.Regex.Match(str,“((?<=Verification Code: ).*)”).ToString


1 Like

Hi @Puneet_Singh

To be more precise and only get numbers please try this

VerfCode = System.Text.RegularExpressions.Regex.Match(str,“(?<=Verification Code:\s)\d+”).ToString

PS: If you copy paste replace the inverted comma in your code again


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