You’d think after 18 months of working on the Kubi Client, I would be able to do MIME structures in my sleep. But I had to look it up again today, so I’m putting this here so I can find it again. Also, I figure if I need to look something up, someone else out there may find it useful.
There are three commonly-used Content-Type headers for structuring MIME messages:
- multipart/mixed for adding attachments to a message,
- multipart/related for combining inline images with a message, and
- mulitpart/alternative for collecting different representations of a message.
For example (indentation is just for cosmetic presentation):
Content-Type: multipart/mixed; boundary="mixed-boundary"
This is a multipart message in MIME format.
Content-Type: multipart/related; boundary="related-boundary"
Content-Type: multipart/alternative; boundary="alternative-boundary"
<html><body><p>This is the HTML message.</p></body></html>
This is the plain text message.
(.. jpeg data ..)
Content-Type: application/octet-stream; name="file.dat"
Content-Disposition: attachment; name="file.dat"
(.. file.dat data ..)
There. As Maude said, “Now I’ll always know where it is.”