Reading IMAP email body in plain text



Hi Three,

I am having trouble reading email body as plain text. I am using uiPath.Main.IMAP.Activities.GetIMAPMailMessage to read emails of my gmail account. Everything seems working file except the body which I read through Mail.Body gives me content with html tags.

Is there a direct way in uiPATH itself to get the readable text instead of html content of it?

Here is how I am trying to get email attachment and body…



Outlook mail activity gives you text directly without html tags @bantuk (or) You need to use this
Regex.Replace(item.Body, "<[^>]+>| ", string.Empty)


I can not use Outlook so second option I can go for. However this replace converts entire text into a single line text. :slightly_smiling_face:

I want to treat New Line separately. Is there a way to do that?

My text is like this:

Employee ID: 12345

Employee Name: John D

Group: RSR

Which becomes:

EmployeeID:12345Employee Name:JohnDGroup:RSR



Did u solve this issue, because I am also having the same problem.


How to get the mail body as it is…
eg: My mail body is
but I am getting the output as
Does anyone know how to solve this issue. @sreekanth @bantuk


Instead of “string.Empty” you can use “Environment.NewLine” which will add new line.


First Replace br , div , tr tags with Enviornment.Newline and then replace the string with Regex.Replace(msg.Body,"<.*?>",string.Empty)…This gives the plain text in correct format.