Industry guru Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, Google AdSense, MySpace, Sony PSP, Apple iPod, Mp3 players, management, Linux, SEO, Mac OS X, Facebook, Twitter, LinkedIn and Microsoft Windows.

Why is my HTML email all messed up?

Dave, I have a problem which I know that many other users have, certainly of Macs, and maybe of other machines as well: Sometimes when I look at an email which has been sent to me which is clearly *supposed* to be rendered in html in my reader, all I actually see is a bunch of html code gobbledygook.

As you can imagine, the email is completely unreadable.

I have searched and searched for a way to clean this sort of email up so it's readable, but to no avail. I have been told that the problem is that the email sender does not have some sort of code set correctly, and that some mail programs will overlook this (which I guess explains why they keep sending this garbage, maybe not enough people complain), but that some, such as my Mac's, will not. Help!


Dave's Answer:

I've seen this crop up on occasion too and it's darn frustrating. From experimentation, it appears that there are two basic ways that an email message indicates that it's written in HTML format, and both revolve around something called the Multipurpose Internet Mail Extensions, MIME.

In the simplest case, the message is sent purely as HTML and there's an additional header added to the message that's Content-type: text/html. Omit that, or have it munged in transit and the nicely designed HTML message ends up being complete gobbledygook, as you see. Some tools at least add a line or two that's hidden when rendered in HTML but visible otherwise that says something like "You need an HTML capable viewer to read this message. If you're seeing this, you need to upgrade, or you can go to

The other, more complex, way to send an HTML message is to actually send multiple versions of the message, one that's just plain text, and one that's a fully detailed HTML message. This is done through what's called a "multipart alternative" message and its headers are a bit more complex. Here's an example:

Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_001B_01C52196.92F3CF30"
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
Importance: Normal

This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C52196.92F3CF30
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

here's where the plain text part appears

------=_NextPart_000_001B_01C52196.92F3CF30
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

and this is the html part

------=_NextPart_000_001B_01C52196.92F3CF30--

Basically, you're getting the HTML message, but your mail program just isn't recognizing it as being formatted in one of these two ways (probably the former, I'm guessing).

The fix? If you can edit the message headers (In Microsoft Entourage, you can only edit the body, for example) then just add in the header Content-type: text/html. If not, you could try saving it as a ".html" file then opening it in Safari, Firefox or your favorite browser.

Either way, that's a pain and it'd be easier to communicate with the sender to find out why their mail program isn't creating proper and valid headers.



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Let me add something to this... I had about 500 messages with munged up HTML in one of my folders. I wanted to keep those messages, and I wanted them to be readable. Here's what I did:

* Exported them all to a text file (actually an .mbox file).
* Edited the text file with a text editor.
* Did a global replace on Message-ID: to add Content-Type: text/html before the Message-ID:
* Saved the result
* Imported the modified .mbox file into Apple Mail.
* Replaced the munged messages with the "fixed" versions.

You can do a lot with a text editor. :) Thanks for the tip, it was just what I needed to complete the fix.

Posted by: ruminator at June 26, 2005 11:34 PM

Apple G4 laptop 17", OS 10.4.5, Eudora 6.2.3
This really no problem for me, but incredibly strange! When writing a message in the body of a Eudora e-mail, if I type the word "punishment," it immediately turns red! This occurs only with this word, and I can not change it to black by Edit > Text > Color > No color, or Special > Settings... > Styled Text > Send plain text mail only, or changing fonts, or size, and I didn't paste any styled text in the e-mail. Isn't that weird? It's no problem, because my e-mail recipients receive "punishment" in black. Is this trying to tell me something? Roy Barker

Posted by: Roy Barker at March 10, 2006 6:07 PM

Simple solution, Roy: you either have a spell checking system that doesn't know the word "punishment" or you have some sort of macro typing shortcut application installed that is triggering from the word you type. That's VERY weird, however, I agree. ;-)

Posted by: Dave Taylor at March 10, 2006 10:46 PM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]