Fetch Email and get a string from fixed Format

Hello,
I need to fetch Unread Emails and need to Fetch a number.
The Subject of Emails will be :

For Your Information: Standard Purchase Order 453635467, 0 has been Rejected.

I need to fetch “453635467” this number from Each Unread Mail Subject.

Any help or suggestion would be appreciated.

Thanks.

Hi @Gagan_Chaudhari

You can use Regex to extract the number from the string.

(?<=Purchase Order )\d+

In Assign Activity

PONum = System.Text.RegularExpressions.Regex.Match(emailSubject, "(?<=Purchase Order )\d+").Value

Thanks, I got the value.

Just need one more thing.
Because due to one space Regex was failing

In Subject Line due additional [space] may come,
e.g
For Your Information: Standard Purchase Order[space]453635467, 0 has been Rejected.

For Your Information: Standard Purchase Order[space][space]453635467, 0 has been Rejected.

For Your Information: Standard Purchase Order[space][space][space]453635467, 0 has been Rejected.

How to overcome from this.

Thanks.

@Gagan_Chaudhari

Use this

PONum = System.Text.RegularExpressions.Regex.Match(emailSubject, "(?<=Purchase Order +)\d+").Value
1 Like

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