QuickStudy: MIME

12.06.2006

Today's Internet mail system is still limited by the legacy of its forebears and can only reliably carry messages that are entirely ASCII text. Before nontext content, such as an image or a sound, is sent through the e-mail system, it is usually encoded into text characters using a system called Base64. MIME also provides an alternative called "quoted-printable" that is suitable for character sets that are mostly ASCII-compatible. If you ever see the characters "=20" or just "=" at seemingly random places in the text of a message -- especially one that has been forwarded numerous times -- those probably are attributable to text that was incorrectly decoded from the quoted-printable encoding.

Support for multipart, compound documents

When you send an e-mail with an attachment, your e-mail program creates a two-part message. The first part contains the text of your message, and the second part, the attached file (Base64-encoded). MIME specifies how these two parts combine to form a single message. A message may have any number of parts, and each one can contain multiple parts.

MIME has been adapted as a compound document technology for Web pages. Most Web pages consist of an HTML file, a set of image files, and perhaps some audio and video files. To view such a page off-line, you must save all of those files. Many browsers give you the option of saving just the HTML file, saving the HTML file and all image files to a directory, or saving it all as a single file. Pick the last option, and your browser will save the HTML and image files as a single multipart MIME document with an .mht extension. If you view this compound document with a text editor, you'll see the multiple parts separated by boundary lines and images encoded with Base64.

Online resources