login about faq

I have an mht file I’m trying to email from my website. Not clear the best way. Can you recommend?

asked Sep 30 '14 at 09:51

chilkat's gravatar image

chilkat ♦♦

MHT and EML (email) are both MIME. MIME is a format that is fundamental to much of Internet communications and technologies, and therefore it's a good thing to know the basics of it. For example, HTTP requests and responses are also MIME.

The only difference between MHT and EML is the intent for how the MIME is to be used. In the case of EML, it is for email and therefore the MIME headers will include fields such as Subject, To, From, etc. In the case of MHT, it is an HTML web archive with the HTML images embedded within the MIME as "related items". The MHT will not contain headers such as Subject, To, From, etc.

EML and MHT embed HTML images within the MIME in the exact same way. The images are located under the multipart/related enclosure, and they are referenced from within the HTML as either Content-ID's or URLs (using Content-Location's).

Given that the files are the same format (except for differences in what headers are present), the reason for naming one "MHT" and the other "EML" is so that each has a different file extension and thus can have different default programs associated with them (.mht is associated with Internet Explorer, and .eml is associated with your default email client, such as Thunderbird).

You should be able to right-click on a .mht and open it in Thunderbird. You'll see the "email" but without Subject, recipients, From address, etc.

There is one big "gotcha" here. The HTML rendering engines within different programs vary in capabilities. A browser is typically more sophisticated than an email client. An email client is unlikely to run embedded Javascript that may be contained within the HTML (and within a .MHT, because the .js portions will also be embedded as related items). Therefore, if your MHT contains complicated and dynamic HTML, then it probably is not good for email. Even if it renders reasonably well in your local environment, you don't exactly know how it will render in other environments. Therefore, the MHT should be relatively simple HTML that is straightforward and sticks to common features, and should not embed Javascripts.

If your MHT contains HTML that is reasonable, then it's only a matter of loading the .mht into a Chilkat.Email object via the LoadEml method, set the Subject and From properties. Add some recipients by calling AddTo, AddCC, etc. one or more times, and then send.


answered Sep 30 '14 at 10:05

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Sep 30 '14 at 09:51

Seen: 4,093 times

Last updated: Sep 30 '14 at 10:05

powered by OSQA