# Email String Manipulation

**URL:** <https://forum.uipath.com/t/email-string-manipulation/331706>\
**Category:** Activities\
**Tags:** string-manipulation, question, mail, system, activities\
**Created:** [23.Июль.2021 03:20:59 UTC](https://forum.uipath.com/t/email-string-manipulation/331706 "2021-07-23T03:20:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [23.Июль.2021 03:20:59 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/1 "2021-07-23T03:20:59Z")

</div>

Hi Guys,

I am extracting data from hundreds of emails and was wondering how I could extract certain type of words right after certain type of text from a long string.

from below, i want to retrieve  
[guest1.test@test.com](mailto:guest1.test@test.com) and [guest2.test@test.test.test](mailto:guest2.test@test.test.test)

since they are always in the same format, I want to manipulate my email string to retrieve emails after "From: " and assign it to variables and store it in a datatable.

any guidance on how to store two (or more) emails after text "From: " would much be appreciated!!!

e.g.  
Subject: RE: New supplier testPerson approval & testrequired for ticket 12312321312313  
From: (test guest) **[guest1.test@test.com](mailto:guest1.test@test.com)**  
To: (test) [test.test@test.test.test](mailto:test.test@test.test.test)  
Date: 9/06/2021 9:41:19 a.m.  
Approved

Subject: RE: New supplier approval & testrequired for 1376611  
From: (test) **[guest2.test@test.test.test](mailto:guest2.test@test.test.test)**  
To: (test guest2 ) [testestest.test@test.co.test](mailto:testestest.test@test.co.test)  
Date: 3/06/2021 12:43:16 p.m.  
Approve  
Guest2

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [23.Июль.2021 04:10:07 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/2 "2021-07-23T04:10:07Z")

</div>

@KL1 - Please check this Regular expression…

 ![image](https://global.discourse-cdn.com/uipath/original/3X/8/4/845d39e5ca1a4a420355777b57737c9df0556956.png)

> **[regex101: build, test, and debug regex](https://regex101.com/r/4l99jU/1/)**
>
> Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

Hope this helps…

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [26.Июль.2021 02:09:24 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/3 "2021-07-26T02:09:24Z")

</div>

do you have any idea on how I could store those multiple string values (Emails) and feed it into different variables?  
eg.  
var1 = 1st email  
var2 = 2nd email

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [26.Июль.2021 02:28:23 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/4 "2021-07-26T02:28:23Z")

</div>

Is there a way to index certain words (e.g. “From:”) and explicitly assign following string to different variables?  
e.g.  
1st “From:” (0) → following email address gets stored in array [0]  
2nd “From:” (1) → following 2nd email address gets stored in array [1]

and

var1 = 1st email  
var2 = 2nd email

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [26.Июль.2021 02:32:03 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/5 "2021-07-26T02:32:03Z")

</div>

@KL1 - Sure … I will show you .

Do you always get only 2 email IDs ? or more is possible??

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [26.Июль.2021 02:37:13 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/6 "2021-07-26T02:37:13Z")

</div>

will always look for 2 email ids but would like to know how to get more as it could be a possibility for my other text search please

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [26.Июль.2021 02:45:53 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/7 "2021-07-26T02:45:53Z")

</div>

@KL1 - Please check this…  
[Regex\_KL1.xaml](https://forum.uipath.com/uploads/short-url/te5VDcyFc3en17ztuTmjdBoeoBK.xaml) (7.1 KB)

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [26.Июль.2021 23:41:51 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/8 "2021-07-26T23:41:51Z")

</div>

Hi Prasath,

thanks for your suggestion but when I read my file (word), below is the string I get from it.  
Dont think this string format retrieves the emails I need from your suggestion solution.  
How would I get the emails from below string?  
Think the weird square boxes are confusing the regex

test1.test1@test.test.nz & test2.test2@test.test.nz

 ![image](https://global.discourse-cdn.com/uipath/original/3X/3/a/3a78fa97cd7bc258da94de975c8f4fd5a08516c4.png)

Subject: RE: New supplier Designated Person approval & declaration required for ticket 1376611From: ( test) test1.test1@test.test.nzTo: (testFPSC test) test.test@test.co.nzDate: 9/06/2021 9:41:19 a.m.  
Approved

testtestI Business test- Commercialtest

Subject: RE: New supplier approval & declaration required for 12311111611From: (testtest) test2.test2@test.test.nzTo: (noneed) test.test@test.test.zzDate: 3/06/2021 12:43:16 p.m.  
Approve  
test

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [26.Июль.2021 23:49:09 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/9 "2021-07-26T23:49:09Z")

</div>

@KL1 - Please check this…

[Regex\_KL1.xaml](https://forum.uipath.com/uploads/short-url/wVZJ2qOde1FND1R1sCJJjT8eExA.xaml) (8.0 KB)

> **[regex101: build, test, and debug regex](https://regex101.com/r/WmlWYR/1/)**
>
> Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [26.Июль.2021 23:49:44 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/10 "2021-07-26T23:49:44Z")

</div>

Update

this is what I see when I copy and paste my retrieved string into regex101 site.

 ![image](https://global.discourse-cdn.com/uipath/original/3X/6/e/6e86b3f48c8c0b4637a7855561ed152e5b469493.png)

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [27.Июль.2021 01:14:25 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/11 "2021-07-27T01:14:25Z")

</div>

hI Prasath,

Any idea on how to retrieve emails from below String?

think the U+0008 is causing the regex to not function properly

 ![image](https://global.discourse-cdn.com/uipath/original/3X/6/e/6e86b3f48c8c0b4637a7855561ed152e5b469493.png)

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [27.Июль.2021 01:20:31 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/12 "2021-07-27T01:20:31Z")

</div>

@KL1 - Please share the sample text file.

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [27.Июль.2021 01:33:11 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/14 "2021-07-27T01:33:11Z")

</div>

[BEST BLOOMS LIMITED Exhibit 100 .docx](https://forum.uipath.com/uploads/short-url/7tFjvkNfn8bg3c5Yf4JTbbqX3Dw.docx) (12.7 KB)

Can you please read from word rather than text and see if you can retrieve the emails? For some reason the regex isnt working when the string is read straight from the word document

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [27.Июль.2021 01:43:40 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/15 "2021-07-27T01:43:40Z")

</div>

@KL1 - I don’t see any issues with the initially provided Regex…  
[Regex\_KL1.xaml](https://forum.uipath.com/uploads/short-url/i5CNXwmrygGOHK4yyU3zBMJbmsg.xaml) (8.1 KB)

Please check this…

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [27.Июль.2021 01:57:53 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/16 "2021-07-27T01:57:53Z")

</div>

[BEST testLIMITED Exhibit 100.txt](https://forum.uipath.com/uploads/short-url/50j2Mu6bWQ4iRyybwmKvFwJlaFt.txt) (451 Bytes)

can you try reading above file?  
below is what I get from UIpath when executed…

 ![image](https://global.discourse-cdn.com/uipath/original/3X/6/6/66cf8b49caec1a7b95838fcc4c3c1f758b55ae8f.png)

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [27.Июль.2021 02:07:44 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/17 "2021-07-27T02:07:44Z")

</div>

@KL1 - Have you tried the recent workflow which I shared???

You only asked me to try with Word file which I tried and got the result…I am not sure, what is your exact requirement?? Can you please clarify…

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [27.Июль.2021 02:14:49 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/18 "2021-07-27T02:14:49Z")

</div>

below is what I get from opening your latest xaml. hence uploaded txt version which also doesnt work.

 ![image](https://global.discourse-cdn.com/uipath/original/3X/8/a/8a6c3e70280b6ce8ea106f886398d6f7044dc794.png)

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [27.Июль.2021 02:17:11 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/19 "2021-07-27T02:17:11Z")

</div>

@KL1 - Please install the below package and Use the activity “Read Text” to read the docx file directly…

![image](https://global.discourse-cdn.com/uipath/original/3X/7/5/7539d7d85963664917c3a3045d861d841be2dc21.png)

 ![image](https://global.discourse-cdn.com/uipath/original/3X/d/b/db9911dfe5fecc23abd7ebe0d0c8e149eb61cd08.png)

---

<div class="post-metadata">

**Author:** ![KL1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kl1/32/203659_2.png) [@KL1](https://forum.uipath.com/u/KL1)\
**Post date:** [27.Июль.2021 02:25:16 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/20 "2021-07-27T02:25:16Z")

</div>

oh it does work indeed. Do you have any idea why it might not be work when I copy the work flow to my existing workflow? (variables have been copied as well.)

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [27.Июль.2021 02:26:30 UTC](https://forum.uipath.com/t/email-string-manipulation/331706/21 "2021-07-27T02:26:30Z")

</div>

> [@KL1](#):
>
> oh it does work indeed.

Great…One down…

> [@KL1](#):
>
> Do you have any idea why it might not be work when I copy the work flow to my existing workflow? (variables have been copied as well.)

Not sure…Did you get any error??
