Avg. Rating 4.0

Problem

You are sending HTML formatted emails but people with text-only email support are seeing the HTML source code in their email client or webmail.

Solution

Some email clients are text only and don't understand HTML content. With ColdFusion it simple to send multi part emails using the <cfmail> and <cfmailpart> tags.

Detailed explanation

To create an email that can be viewed in text only and HTML email clients, you simply need to add two <cfmailpart> tags inside your <cfmail> tag, For the first one add the type="text" attribute, on the second one, set the type attribute value to "html".

Here is an example:

<cfmail to="dummy@email.address"
  from="mysite@email.address"
  subject="HTML email that degrades"
  type="html">
  <cfmailpart type="text" wraptext="74">
Hello,
This email would look much nicer in an 
email client that can read HTML content.
-----------------------------------------
This is a good example of how ColdFusion 
makes complicated things really easy.
  </cfmailpart>
  <cfmailpart type="html">
    <p>Hello,</p>
    <p>You have a nice email client that lets you see HTML
    content</p>
    <hr />
    <p>This is a good example of how 
    <strong>ColdFusion</strong> makes complicated
    things really easy.</p>
  </cfmailpart>
</cfmail>

It is important to note that the type attribute of the cfmail tag is still set to simply html.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes