Reading IMAP email body in plain text

email

#1

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…
image

Thanks,


#2

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


#3

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

Thanks,


#4

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


#5

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


#6

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


#7

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.