Have Exchange/Outlook process html tags in SMTP mail

exchange-2007htmloutlook-2010smtp

I am working with a third party application that sends simple SMTP email messages. The application doesn't respect line breaks or multiple spaces so the resulting email is barely legible.

Since the message comes through our SMTP server Outlook sees it as plain text. Can I including html tags in the SMTP mail message and have Outlook process the tags to make the output more user friendly?

Best Answer

SMTP mail typically uses the MIME message format. This format is a very flexible system that allows a single message to contain several sections (called "parts"), each using it's own separate encoding and type.

Now, SMTP mail is very old functionality and it actually predates the MIME format and so it will support message that are in that same format. typically, that is the way the most simple mail sending application will handle it: just as a bunch of text.

In practice, a MIME mail message is made of a set of headers followed by the message body. One of these headers indicates just how the message is encoded. If the message body is plain text, that header will read:

Content-type: text/plain

And if the message body is made of HTML it will usually be

Content-type: multipart/related

(or sometimes straight text/html)

Which tells the mail client that there is multiple parts in the message. At this stage, each part must indicate what type it is supposed to be in (in addition to several other parameters).

All that to say that, if you mail application sends the message as plain text and you want to convert that as HTML, you will have to, at the very least, change the message's content-type header in addition to change the message body itself.