Embedding image in oft template mail


I’m trying to put an encode Image base64 into an oft template mail created with aspose email.
Here my code :

	public void generateOFT()
		String htmlBody = "";
		String savePath = "C:\\test.oft";
		MailMessage message = new MailMessage();
		message.setFrom(new MailAddress( "test@test.it", "test@test.it", false));
		MsgSaveOptions options = SaveOptions.getDefaultMsgUnicode();
		message.save(savePath, options);

you can find the txt file attached method.zip (29.5 KB) with the htmlBody variable initialized. It’s to long to past here.

When I open the oft file I have this view :

image.png (3.2 KB)

So as you can see the embed image is not charged.
Could you please help me.

Best Regards,



Creating MailMessage from base64 encoded Image using the API is not supported at the moment. We are analyzing your requirement in this regard. Meanwhile, you can use the HtmlLoadOptions to get this working as shown in following code sample change.

Sample Code

MailMessage message = MailMessage.load(
                new ByteArrayInputStream(htmlbody.getBytes()),
                new HtmlLoadOptions());
1 Like

Hello @kashif.iqbal,

Thank you very much!!!
It works!!!

Have a nice day :slight_smile:



You are welcome.