Mail messages issue

Hi all,

I have a problem with reading emails.

I can extract the subject via mail.subject, while when I try to extract the body via mail.Headers(PlainText) it goes into error.

I tried to print the collection items via mail.Headers and “plain text” does not exist, only htmlbody.

How come? What does it depend on since on another mail I can extract plain text?

Thanks

mail.Body for text
mail.BodyAsHtml() when HTML mail

when using the header keys we need to surround with "

1 Like

mail.body always extracts the body to html, considering I have to do a search for a specific pattern I don’t want all those extra characters.

“PlainText” doesn’t exist, unfortunately

What does it depend on whether an email is html or not?
I would like only what I display in the body, is that possible in these cases?

Thanks

I crosschecked at my end for a html mail and was extracting plain text.

grafik

vs:

But before proceeding further as within different combinations (Activity, Targetframework, versions…) let us clear following before:

  • Studio Version
  • UiPath.System.Activities Version
  • Mail relevant Packages and its version
  • involved Activities
  • TargetFramework
  • we assume VB.Net is used

Studio 2020.10.4
System.activities 20.10.3
Vb.net
Uipath.Mail 1.10.5
Get imap is the activity used to get the email.

The strange things is: in another project (with the same web mail server), with the same packages and studio version, i’m able to get the “PlainText” without any issue.

so I wanted to understand what it depends on and how I can solve it

upgrade UiPath.Mail at first. We got often a few surprises in the past. So its better starting to check issues on the latest packages

just tried with the latest version, in the HeaderCollection i have 18 elements, but not the plain text, just the htmlbody

From Docu

Which not exclude from the statement that we also can see HTML Fragments (e.g. Signatures…) ins some cases.

You can also check different mails (assumed you do not only retrieve 1 email with the get imap mail) and explore the mentioned alternate views.

Quick analysis and prototyping can be done within the immediate panel during debugging:

1 Like

In case it comes in handy for anyone.

Within the mail settings (of the sender) was the option “send email as html”.

With that option removed, plain text became available again.

Now another problem opens up. Since I receive emails from many different addresses, if one of them had this option enabled I would not find plainText and the robot would return an error.

What is the difference between body (which returns both html body and plain body based on the email sent) and headers(“PlainText”), which if it does not exist goes to error?

At least you can defensive handle by checking if the key exists or not:
YourMailVar.Headers.AllKeys.Contains(“YourKeyName”)

was this also explored

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.