kkpatel
(Kamal)
October 11, 2021, 11:16am
1
Hi Team
I need to read only a comment written under a keyword Reject in an outlook email.
Like:
Hi Team
Reject.
Price is too high.
Regards
Supplier Team
In this email body I just need to fetch the string after the keyword Reject i.e “Price is too high” not the signature of the email.
How can I achieve this ?
You can reas the body of the email and then use regex to get the part after that keyword ‘Reject’
Also If you need extract multiple lines between the Reject and the Regards keyword
strEmailBody.Split("Reject")(1).Trim.Split("Regards")(0).Trim
If there will be only one line then you can use
strEmailBody.Split("Reject")(1).Trim.Split(Environment.Newline)(0).Trim
ppr
(Peter Preuss)
October 11, 2021, 11:21am
4
refering to group
(?<=Reject)(?:[\.\r\n]+)(.*?\r?\n)
1 Like
kkpatel
(Kamal)
October 11, 2021, 11:21am
5
@THIRU_NANI @rahulsharma
If I use regex and try to fetch the strings after Reject key word then chance is that the signature of the email will also come.
Also the signature of a user can be anything that is not our scope. That is an outside entity.
So how can it ignore the signature and only take the comment section ?
you can split using new line that will allow you to neglect the signature, as i sent it above. Or you csn use the regex too as suggested above by Peter
Make sure there are many ways to do thing but try to do it as per your scenario and with complete understanding.
Happy Automating!
1 Like
kkpatel
(Kamal)
October 11, 2021, 11:32am
7
Thanks @rahulsharma . let me try.
ppr
(Peter Preuss)
October 11, 2021, 11:51am
9
checked on Uipath and was working
rahulsharma
(Rahul Sharma)
October 11, 2021, 12:54pm
10
did you try split method? screenshot shows a regex
You can use a regex or you can use the below code to split
strEmailBody.Split("Reject")(1).Trim.Split(Environment.Newline)(0).Trim
2 Likes
kkpatel
(Kamal)
October 11, 2021, 12:59pm
11
it seems easy to implement. I will try.
1 Like
kkpatel
(Kamal)
October 13, 2021, 1:05pm
12
@ppr @rahulsharma @THIRU_NANI
This is working fine if we just test with test data. But regex is not working when i run in my actual process.
That is when it is reading the actual email.
1 Like
ppr
(Peter Preuss)
October 13, 2021, 1:29pm
13
Ok, thanks for feedback. In case of you need further help on this then required sample / further information is to share with us.