HTML Email is a PITA

Email started as text only and everything worked as expected. Then someone (probably a marketing suit. a.k.a. PHB) decided to make it look fancy. Now email messages are so complex that AI and Machine Learning has to be used to determine the “value” of a message. Not to mention the display of the message across multiple clients on various form factors (i.e. phone, tablet, laptop, desktop, smart mirror, TV, refrigerator).

HTML email makes use of Multipurpose Internet Mail Extensions (MIME) that would also be used to send attachments.

MIME messages can be visualized as a set of papers and folders all stuffed into one envelope. How these papers and folders are organized inside the envelope makes the difference in how the elements are displayed.

Each paper represents a block of text, an image, or a file.

A simple message containing a plain text block and a PDF attachment would have two pieces of paper in one folder. The folder would be “multipart/mixed” meaning there is no relationship between the two papers found within.

A simple HTML message with a PDF attachment would have three papers: plain text, HTML text, and PDF attachment. The two text papers would be in a folder “multipart/alternate” meaning the client can use either paper within to display the message. This folder and the PDF attachment would then be put in another folder “multipart/mixed” meaning there is no relationship between the folder and the PDF.

An HTML message with an embedded image would have three papers: plain text, HTML text, and image. The HTML text and the image would be in a folder “multipart/related” implying that the image is related to the HTML text. This folder and the plain text paper is placed in a folder “multipart/alternate” meaning the client can display either the plan text message or the HTML+image version.

An HTML message with an embedded image and a PDF attachment would have four papers: plain text, HTML text, image, and PDF. The HTML text and the image would be in a folder “multipart/related” implying that the image is related to the HTML text. The “related” folder and the plain text paper is placed in a folder “multipart/alternate” meaning the client can display either the plan text message or the HTML+image version. The “alternate” folder and the PDF are placed in a folder “multipart/mixed” which implies no relationship.

Sometimes the mail client makes a mistake when assembling a message with the parts as shown in the previous paragraph. This mistake is usually in the outermost folder type where “multipart/related” is used instead of “multipart/mixed”. This mistake ends up hiding the PDF attachment at the destination as the client thinks the PDF is part of the body and not a separate element.

Bookmark the permalink.

Comments are closed.