Getting certain part of a long strict from an Outlook Email

Hello there,
I am trying to assign a certain part of an email to a String variable (lets call str1).

Here is one example of the email (email1_ss):

Despite the email screenshot above UiPath sees the email like below:

Dear MyTool+ Team,\r\n\r\nplease find enclosed the data sheets and quotations for the following special device/devices.\r\n\r\nDevice/Devices*:\r\n\r\n-* A7B91503737306\r\n\r\nUsed in:\r\n- Swg. No.:

Normally I try to get and assign “A7B91503737306” part to a String variable (str1).
I use the below method to doit:
str1 = String2.Split(" "c)(0).ToString

But the it turns out that the str1 is “A7B91503737306\r\n\r\nUsed” not “A7B91503737306”

I think there is no space between the last character of “A7B91503737306” and “Used”

Do you have any suggestions for solution?

Hi @Saltukhan_Dura

We can try using Regex, but before that we should make sure what part of this “A7B91503737306”
stays same
e.g A7B comes in every other scenarios??


1 Like

If that is the case we can use this regex, only output the desired val



1 Like

Answer: No it doesnt. Those numbers are changing in each scenario. The length, characters always change.

I didn’t understand this solution.
I used Regex in an earlier solution but I couldn’t solve it.

Now at first step I used Regex then I replaced a reference word like this " Used" instead of “Used” (adding 1 character Space)

That solved my problem

But I still want to understand your solution. Could you pls explain a little deeper?

Could you please share the text file or the provide the original text here? Writing the Regex pattern from the screenshot sometime won’t work…

There is this site
which also us to make expressions and extract the required keyword based on expression
here is how it looks
So it will look for the starting alphabets and starts extracting the word , \d+ means digit which comes after

Hope this helps to u grasp the idea


We can add limit to the digits at the end
as u said the length remains same
so we can do this for accuracy

no it doesn’t stay same. It always change.

Device/Devices*: \r\n\r\n -* A7B91503737306\r\n\r\nUsed in:

does any word remains same in this string in every scenario?

“Used in” and “Device/Devices” stays always same.

“Used in” repeats itself if there is any other codes like “A7B91503737306” in the email.

“Device/Devices” exists only 1 time in the email. Always fixed

Can u try using this method??
See the attached file

word_extraction.xaml (7.7 KB)

It solved my problem.
But there is another problem.

I tried it with another potential code
I used “6GK1114-161616” instead of “A7B91503737306”

The result is “6GK1114”

Is it possible to get “6GK1114-161616” ?

The same process will work on this “6GK1114-161616”, if u first remove this “-” dash

1 Like

Thank you

Your very Welcome…!

Happy Automation


1 Like

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