Tim Cracked The GMail - CFMailPart Puzzle!

Posted August 24, 2006 at 1:44 PM

Tags: ColdFusion

My main man, Tim, just cracked the puzzling way that GMail handles multi-part emails. As I had posted before, if you send an email to GMail with a rich text (text/html) part and a plain text (text/plain) part, GMail would always ignore the richly formatted text part and show the plain text. It turns out, as Tim, shows me, the order of the CFMailPart tags are important. In all of my examples, I always put the text/html part first:

 Launch code in new window » Download code as text file »

  • <cfmail
  • to="liz@campus-cutties.com"
  • from="emy@campus-cutties.com"
  • subject="Great Photo Shoot!">
  •  
  • <!--- Send rich formatted part. --->
  • <cfmailpart type="text/html">
  • Hey Em, you looked <strong>red hot</strong> sexy
  • at the photo shoot today!
  • </cfmailpart>
  •  
  • <!--- Send plain text part. --->
  • <cfmailpart type="text/plain" wraptext="60">
  • Hey Em, you looked pretty at the photo shoot today!
  • </cfmailpart>
  •  
  • </cfmail>

This worked for most email clients, but for the increasingly popular GMail, it would only show the plain text part! Well, as Tim pointed out, if you switch the order of the mail parts:

 Launch code in new window » Download code as text file »

  • <cfmail
  • to="liz@campus-cutties.com"
  • from="emy@campus-cutties.com"
  • subject="Great Photo Shoot!">
  •  
  • <!--- Send plain text part. --->
  • <cfmailpart type="text/plain" wraptext="60">
  • Hey Em, you looked pretty at the photo shoot today!
  • </cfmailpart>
  •  
  • <!--- Send rich formatted part. --->
  • <cfmailpart type="text/html">
  • Hey Em, you looked <strong>red hot</strong> sexy
  • at the photo shoot today!
  • </cfmailpart>
  •  
  • </cfmail>

... such that the text/html part is second, GMail will indeed show the richly formatted version! This continues to work in MS Outlook as well. Thanks Tim, you just rocked my world!

Download Code Snippet ZIP File

Comments (6)  |  Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page



Adobe ColdFusion 8.0.1 Update - Helping Programmers To Be Signifanctly Less Girlie - Download ColdFusion 8 Update 8.0.1 Now.

Reader Comments

cfmailpart should be great, but then along comes blackberry and a client using Eudora 3.1 and all the rules go out of the windows because neither of those clients handles the mailpart tag correctly. i'm royally stuck now because our client is desperate to use HTML but some of the users just can't see it. Know any workarounds?

Posted by Edward on Nov 24, 2006 at 7:08 AM


Ed,

While I do not know this for a fact, I heard someone one time talking about this type of issue. I think they came up with a solution that they put in the plain text content right into the emails (as if there were no parts) and then put a CFMailPart for HTML emails at the end. For clients that couldn't handle the mail part, they saw the text version and then clients that could handle it (and HTML emails) saw the HTML version.

Of course, I have NOT TESTED this, so take it with a grain of salt.

Posted by Ben Nadel on Nov 24, 2006 at 9:54 AM


Thanks for the quick response Ben, I just tested the theory and it didn't work in Eudora. Then again we're talking about a main client so old that it predates any modern standards for emails! Oh well, I'll keep trying. Thanks again for your help.

Posted by Ed on Nov 24, 2006 at 10:07 AM


Ed,

Is there anyway from the email address to tell if the user is using Eudora? If that is the case, you actually just send a different email to those users.

If not, I am out of suggestions. Sorry.

Posted by Ben Nadel on Nov 24, 2006 at 10:10 AM


I wish! :-)

Posted by Ed on Nov 24, 2006 at 10:12 AM


Excellent... If I weren't primarily a Gmail user, I probably wouldn't have even noticed this annoyance. Thanks for posting this for the Google spiders to find. :)

Posted by Chris Peters on Dec 31, 2007 at 1:57 PM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting