Key Concepts of MHTML

As a document format for Multipurpose Internet Mail Extensions (MIME) e-mail, HTML has been available for years in the form of the text/HTML content type. However, the richness of HTML as an interoperable e-mail format can be achieved only through the use of the MIME multipart/related content type. This content type allows the message to contain an HTML page and other resources, such as pictures and sound, included directly in the MIME hierarchy of the message. This data can be referenced through links from the HTML content and used to complete the rendering of the document. This usage allows the recipient to resolve all the links "locally" that is, without having to use the network.

MIME Encapsulation of Aggregate HTML Documents (MHTML) defines the naming of objects that are normally referred to by URLs and the means of aggregating resources that go together. Two MIME headers, Content-Location and Content-Base, are defined to resolve references to other content stored locally in related body parts. Content-Base gives an absolute URL base, or "starting point", for relative URLs that appear in other MIME headers and in HTML documents that do not contain any BASE HTML elements. Content-Location specifies the URL that corresponds to the content of the body part that contains this header.

The following example shows an MHTML message with a relative reference to an embedded Graphics Interchange Format (GIF).

From: user1@example.com
To: user2@example.com
Subject: An example
Mime-Version: 1.0
Content-Base: http://www.example.com
Content-Type: Multipart/related; boundary="boundary-example-1";type=Text/HTML

--boundary-example-1
Content-Type: Text/HTML; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE

... text of the HTML document, which might contain a hyperlink
to the other body part, for example through a statement such as:
<IMG SRC="/images/ie5_e2k7.gif" ALT="Internet Explorer logo">
Example of a copyright sign encoded with Quoted-Printable: =A9
Example of a copyright sign mapped onto HTML markup: ยจ

--boundary-example-1
Content-Location: /images/ie5_e2k7.gif
Content-Type: IMAGE/GIF
Content-Transfer-Encoding: BASE64

AAAFFDDlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5
NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A
etc...

--boundary-example-1 -