The easiest MIME message to create is one with a single attachment or message part. The bare requirements are:
A MIME-Version header
A Content-Type header, but only if the content is something other than plain text in the US-ASCII character set
A Content-Transfer-Encoding header, but only if the content is encoded in something other than 7-bit US-ASCII text
Not very exciting, is it? This means that the simplest MIME-compliant message is just an RFC 822 simple text message with an added MIME-Version header. That’s the beauty of backward compatibility. For example:
From: Bill Clinton <[email protected]> To: Al (The Enforcer) Gore <[email protected]> Subject: Argentina Junket MIME-Version: 1.0 Hey Big Al, We haven't been to Argentina, have we? Can we schedule that in the next couple of months? I'd like to find where Dan Quayle found those little dolls ... Bill
Of course, if the content is something other than simple US-ASCII text, we have to get a bit fancier:
From: Bill Clinton <[email protected]> To: Al (The Enforcer) Gore <[email protected]> Subject: Map of Argentina MIME-Version: 1.0 Content-Type: image/gif Content-Transfer-Encoding: base64 R01GODlhJQA1AKIAAP/////78P/omn19fQAAAAAAAAAAAAAAACwAAAAAJQA1AAAD7Qi63P5w wEmjBCLrnQnhYCgMlwh+pkgqqeC9XrutmBm7hAK3tP31gFcAiFKVQrGFR6kscnonTe7FAAad GugmRu3CmiBt57fsVq3Y0VFKnpYdxPC6M7Ze4crnnHum4oN6LFJlbn5NXTN7OF5fQkN5WYow BEN2dkGQGWJtSzqGTICJgnQuTJN/WJsojad9qXMuhIWdjXKjY4tenjo6tjVssk2gaWq3uGNX U6ZGxseyk8SasGw3J9GRzdTQkyliHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz 7itICBxIsKDBgwgTKjyYAAA7
In this case, we have sent an image instead of text. Since the content was not US-ASCII text, we had to add a Content-Type header and a Content-Transfer-Encoding header to properly describe the data. Since we stated that the data was encoded with the base 64 algorithm, the body of the message must contain only base64 encoded data.
Audio or video files could have been sent in the same manner. The Content-Type header would change appropriately to denote the media type enclosed.
If we wanted to add a description to the image that was sent, we have limited options with a single part message. We can add a Content-Description header, like this:
Content-Description: "The attached image is a really small world map with no real information on it. For a real map of Argentina, see: http://www.lonelyplanet.com/dest/sam/graphics/map-arg.htm"
The problem with the Content-Description header is that most MUAs won’t display it directly to the user. The user might never see the explanatory details, which might be important.
We could also put more information in the Subject line, which does get displayed to the user, but most MUAs only display the Subject as a single line. We would like to be able to construct a message that contains both an image and its description. The solution to this problem is multipart messages.
18.117.107.90