Tim Cracked The GMail - CFMailPart Puzzle!
Posted August 24, 2006 at 1:44 PM
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
Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Newer Post
Randomly Sorting A ColdFusion List
Older Post
How Does It Feel To Be An Adobe Certified Advanced ColdFusion Developer?
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?
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.
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.
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.
I wish! :-)
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. :)
This helped me make an internal page, emailing the result to Groupwise. I had the html part first originally and text part second. The emails I got were showing up fine in html format but it had this wierd attachment part.001 which was the text portion.
By switching the order and making the text first, it still achieved what I wanted, which was to show the html part first with no attachments and then also have a text part if the user was viewing text only
One more scenario for fun:
If you have a cfmail tag with one cfmailpart in it of type HTML - Gmail renders empty text, noice!
@David,
Ugg, that is lame. I wonder, do we even care about plain text emails anymore. The only thing I could ever think about was something like a Blackberry. But I assume that by now, even the Blackberry has rich text email capabilities?
So, no one is using the type="html" attribute of the cfmail tag? Not enough control?
@Mik,
I use the type="html" most of the time. I only worry about this when I have a non-html version to offer (which, I spend less and less time worrying about).
True enough.



