How to extract specific information from the body of the Email

hai ,
I am extracting specific content form the email body but when i reading it showing in HTML format but i need only the specific info and that need to be saved in variable .
can anyone suggest how we can achieve this.



  Use any get mail activity like get outlook mail message activity that i have used assign the output from get mail activity to a list<mailmessage> variable. 

Then put an for each function and change the type argument to mail message then from the item returned from the for each activity u can get the body of each mail.



I want to extract only the data circled in red from email.
But when i am using Mail.Body, the whole data of the mail including the previous mail gets extracted.
@Dominic @sreekanth Any ideas on what could be done in this>??


Thanks and Regards.

1 Like

hi @SHAISTA @Raguvarthan @ushu

do you have this workflow?


1 Like

Which one? To extract information from email?


yes :slight_smile:

This is the workflow.
You need to configure the IMAP settings.
MailInfo.xaml (7.2 KB)

1 Like


Refer this post
Capturing data from email - #2 by acaciomelo


1 Like

Do you have any fixed text in that mail body?If yes then you can go with post referred by @arivu96 and use indexof() and substring() to extract required text. @SHAISTA

1 Like

@arivu96 @sreekanth
Please see in the screenshot i have attached.
The format of the mail will be fixed always.
The reply from the sender will always be approve or disapprove.
But in the mail which i have sent to the vendor, i have already mentioned “Please reply with approve or disapprove”
So if i am extracting the body data and applying if condition to check whether the reply is approve or not, the condition always comes true as UiPath fetches the whole email data including the data of the mail i sent.


After extracting the data split using environment.newline take the first line alone check the condition as approve or disapprove.


1 Like

That worked. :slight_smile:

hey i have am concerned that what if i dont have fixed text and getting different reply to my mail totally different or some may be common as well how i can do that

Do you have code example for this?


i m facing the same scenario
but not getting the body of email
can u suggest/…


try to get the body in HTML and then convert that into plain text it will be working

can u elaborate more
i mean the activities to get the text from mail
when m using mail.body it is showing blank messages
tell me how can i get body as html and dn cnvrt it into text?


assign the body of the mail to mail.body(html)
then assign the same to mail.body(plaintext)

did the same but getting error.
html is not declared inaccessible due to its protection level

please share the screenshoot