Embedding image in oft template mail

Hello,

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.setSubject("Object");
		message.setFrom(new MailAddress( "test@test.it", "test@test.it", false));
		message.setHtmlBody(htmlBody);
		
		MsgSaveOptions options = SaveOptions.getDefaultMsgUnicode();
		options.setSaveAsTemplate(true);
		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,

Riccardo

@GreenRic,

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:

Riccardo

@GreenRic,

You are welcome.