Archived Forum Post

Index of archived forum posts

Question:

How to make sure that images are displayed correctly with a mht file

May 07 '15 at 11:37

We are new with Chilkat and we want to send email from a mht file. Our mht file are saved directly in the database and not on a disk. When we send email, all images that are in the mht file are not displayed when recipient receive the email.

Here how we send the mht file:

// Note that the cMail.cMessage.BodyMht is a Byte[] and is the content of a database field.
email.SetFromMimeBytes(cMail.cMessage.BodyMht);

Thank you for your help!

David


Answer

David,

A .mht and .eml are both essentially identical. They are both MIME. The file extension indicates the intended use -- one is for viewing in a web browser, the other for email. Email clients may be more restricted in what they can render within HTML -- regarding javascript, non-embedded images, etc.

What you can do is save the MHT bytes from your database to a file, rename it to use the .eml extension, and then open it in Mozilla Thunderbird. If it doesn't display correctly, then that particular MHT is not suitable for email. How is it no suitable? I wouldn't know without looking. It may have to do with Javascript, non-embedded images, or possibly due to complexities in HTML often introduced by programs such as Microsoft Word, which don't render well as email. The HTML email should be kept fairly simple if it has any chance to be rendered reasonably well in a wide range of desktop email clients, browser-based email clients, and smartphone email clients..