How to create HTML message?

Hi.

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();

license.setLicense(secretPath);

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

MailMessage message = new MailMessage();

message.setSubject(" “);

message.setHtmlBody(”");

AttachmentCollection attachments = message.getAttachments();

Attachment attObj = new Attachment(fileName);

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

attObj.setName(fileNameWithoutFolder);

message.addAttachment(attObj);

MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);

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

mapiMsg.save(outputFileName);

Kind regards,
JP.

								<br>

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:

message.setHtmlBody("");

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.

JP.

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.