Free Support Forum -

How to create HTML message?


Messages that I am creating are text messages. I would like to create an HTML message instead of text message. What should I do?

My code is:

License license = new License();


System.setProperty(“file.encoding”, “UTF-8”);

MailMessage message = new MailMessage();

message.setSubject(" “);


AttachmentCollection attachments = message.getAttachments();

Attachment attObj = new Attachment(fileName);

String fileNameWithoutFolder = new File(fileName).getName();



MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);

mapiMsg.setMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT | MapiMessageFlags.MSGFLAG_FROMME);;

Kind regards,


Hi JP,

Thank you for writing to us.

I have observed that if you keep the setHtmlBody() method with empty string, it will save the message body as Plain Text. In order to avoid this, please include the tags as follow:


This should solve your problem. Please let us know if we can be of additional help to you.

It works. You guys rock!

Thank you.


Hi JP,

You are welcome and thank you for the feedback.

Please feel free to contact us if you have any additional query. We will be glad to assist you further.