CurrentMail.BodyAsHtml

Hello all,

Context:
Using “Use Outlook 365” and iterating through each email filtered, my process was working fine taking “CurrentMail.BodyAsHtml” and passing that to “Create HTML Content” under the Mail activity group. The goal was to send a copy of the body along with some attachments. It was working fine for roughly 3 years and only recently I found out that “CurrentMail.BodyAsHtml” was no longer recognizing the email body as a html object in UiPath and thus throwing an error “No Object Reference”. However, with the same “CurrentMail.BodyAsHtml.ToString” it will print out content. Passing the string form does not format the content.

So my question is, does anyone know whats going on here? It does not make sense to me that .ToString prints out content but not recognized as an Object and even passes the flag “CurrentMail.BodyAsHtml is Nothing”.

What I need to achieve is to pass the body of some email as html content and send that content out again. For now, I have used a workaround to forward the email content, but the formatting is not correct.

Hello @Justin_Soh

In the Use Outlook 365 activity enable the option like “Get as HTML” or update to a version that supports it and if BodyAsHtml is still Nothing then use CurrentMail.Body and set IsBodyHtml = True in your Send Mail activity so it treats the string as HTML.

Cheers

@Justin_Soh,

This is happening because BodyAsHtml property is deprecated in newer Outlook 365 activities and sometimes returns Nothing. Instead, use CurrentMail.Body (which always returns string) and wrap it with Create HTML Content to format it properly. If you specifically need HTML, retrieve it via CurrentMail.Headers("HTMLBody") or switch to Get Mail (classic) which still provides the raw HTML body reliably.

I saw this solution on other topics, but unfortunately, the current activity does not have the option to set “Get as HTML”. This activity is from UiPath.Mail.Activities = 2.4.10

Hi I have tried out this method and the CurrentMail.Body as a string does not bring the html format of the CurrentMail. However, I will explore around more around this method.

Change the Activity because the Use Outlook 365 activity can only send plain text bodies there is no property to tell it to treat the input as HTML.

Use Send outlook desktop mail message then there will be option of body as html select that and pass the variable it’ll send the message as html.