Formate Email text

Hi Team,

I need to Bold the Specific line text in Email reply. Double click on row is not working and triple click to chose whole line is not available in UiPath. I need italics the whole line.

like: those 2 lines and i want last line to show as italic.
Once this has happened, you will receive an email from the business portal stating that access to purchases and/or orders in the business portal has now been opened.

Remember that you must order by the 15th of the month at the latest, so that it can be valid from the 1st of the following month

Hi @Latif

  1. Assign your email body string with HTML formatting:

    Plaintext

    str_EmailBody = "Once this has happened, you will receive an email from the business portal stating that access to purchases and/or orders in the business portal has now been opened.<br><br><i>Remember that you must order by the 15th of the month at the latest, so that it can be valid from the 1st of the following month</i>"
    
    
  2. Pass str_EmailBody into the Body field of your Mail activity (Reply To Outlook Mail Message / Send Outlook Mail Message).

  3. Check the IsBodyHtml property in the activity properties panel.


I also want to include the email which im replying of so the emplyee can see why im asking the detail.

But under Body and i can not add MailMessage variable with the varTexttoemployee varibale which holds the text.
And if under Source mail I include the MailMessage then I am not getting the text i want to send.

Hey @Latif,

I get what’s happening here. Body and Source Mail are two different things, and they don’t mix.

‘Source Mail’ just tells UiPath which email you’re replying to. It sets the subject and recipient. That’s it. It won’t show any text in the email itself.

‘Body’ is where your actual text goes. But it only takes a plain string, not a MailMessage. That’s why you can’t drop your MailMessage variable in there next to varTextToEmployee.

You can fetch the original email body into text, and then join it with your own message. This way you will have original email body and your reply message.

Write this in the Body field:
varTextToEmployee + “<br/ (for new line)><br/ (for new line)>------ Original message ------<br/ (for new line)>” + mail.Body

Keep your MailMessage variable in Source Mail like before.

If the original email has tables or colors and you don’t want to lose that, use this instead:

varTextToEmployee + “<br/(for new line)><br/(for new line)>------ Original message ------<br/(for new line)>” + mail.Headers(“HTMLBody”).ToString

Note: Remove “(for new line)” from inside the br tags. I kept them so that the actual tags are visible.

Turn on IsBodyHtml in the properties panel so that your bold and italic tags actually show up, without this they’ll just print as plain text like .

Body = your text + the old email joined together as one string.

let me know if this works.

Hi Latif,

If you are using the Send Email activity, you can format specific text by using HTML in the email body.

For example, to make the last line italic, you can use:

Once this has happened, you will receive an email from the business portal stating that access to purchases and/or orders in the business portal has now been opened.<br><br>

<i>Remember that you must order by the 15th of the month at the latest, so that it can be valid from the 1st of the following month.</i>

Make sure the email body is configured to use HTML, rather than plain text.

Similarly:

  • <b>Text</b> → Bold

  • <i>Text</i> → Italic

  • <u>Text</u> → Underline

This avoids having to double-click or select the line manually in the email editor.

This activity has no option for HTML text
(Turn on IsBodyHtml in the properties panel so that your bold and italic tags actually show up, without this they’ll just print as plain text like)

@Latif From your screenshot I can see you are using Send Outlook Desktop Mail Message. In this version you will not find IsBodyHtml in Properties. Click the + icon beside Body and check if you have Body as html option. Select that and then you can use your formatting directly. For example:

"Once this has happened, you will receive an email from the business portal stating that access to purchases and/or orders in the business portal has now been opened.

" +
Remember that you must order by the 15th of the month at the latest, so that it can be valid from the 1st of the following month

But one more thing, since your requirement is actually to reply to the existing email, I would use Reply to Email inside Use Desktop Outlook App instead of Send Outlook Desktop Mail Messesage.

Set the original mail in the Email field and put varTextToEmployee in Body using HTML option. This way Outlook will handle it as a real reply and original mail will remain in the conversation.

So no need to concatinate mail.Body manually unless you really want to copy the old body again inside your reply. That can also cause formatting issue/duplicate content.

Try once with Reply to Email + Body as HTML, it should fit your case better.

Hi @Latif,

Click the plus icon of Body, and then Body as html, to add the email body in HTML format. To switch back to the initial option, select the plus menu again, and then Body as text.

Thanks!

Hi @Latif ,
If the issue is still not resolved, you can refer to the screenshot below for a better understanding.

As shown in the screenshot, select “Body as HTML” and then click “Edit in Expression Editor.” I have attached a screenshot below for better understanding.

Thanks,

I tried that.
But by doing that.. my variable vartMailMessage which had the mail im replying to..is the mail text in reply mail and not the Text I added into as HTML.

I want both text.. like orignial message I reply to plus the new text i want to add.

Okay, so as you mentioned, you want to keep the original message along with the new text.

Why not concatenate them like this?

"<b>" & NewText & "</b><br><br>" & vartMailMessage.Body

Thanks

will that keep the layout as it was in orignal mail?

Hi @Latif

Got it, now the requirement is clear.

Since you want both:

  • your new formatted text at the top
  • the complete original email below it

don’t put varMailMessage itself inside the Body because Body expects a String, not a MailMessage object.

Create one final body string, something like:

varFinalBody =
varTextToEmployee +
"

----- Original Message -----

" +
varMailMessage.Body

Then pass varFinalBody to the Body field.

If the original email already contains HTML formatting like tables, colors, signature etc., better use the HTML body instead of .Body, for exampl

varFinalBody =
varTextToEmployee +
"

----- Original Message -----

" +
varMailMessage.Headers(“HTMLBody”).ToString

Keep varMailMessage in Source email as you have now, so UiPath knows which mail/thread you are replying to.

One important point: if varTextToEmployee contains , or
tags, the Body needs to be treated as HTML. If this particular activity/version does not expose HTML body support, I would suggest using Reply to Email inside Use Desktop Outlook App, where you can select Body as HTML.

So basically:

Source email = varMailMessage
Body = your new HTML text + original email body

This should give you both the new formatted message and original mail content in the reply.