Get a Quote Today!   |   + 1 (301) 424 3903




 
  Community
 
Need Help?
Visit our Training page
Request a Quote or Consultation
SIGN UP FOR THE TERATECH NEWSLETTER
 

ColdCuts

Cut: Multi-Part MIME email HTML and ASCII
Cut#: 169 
Cut Date: 01/05/2001 
Cutter: Matt Liotta 
Topic: Appearance 
Overview: How to generate mult-part MIME email messages in CF. In particular ASCII on top, HTML version below. The HTML option of CFMAIL just sends the HTML version and not the plain text too. Some people can't read HTML email in their email program!

Both parts are dynamic from a database and one is the ASCII version of the other.

 

Cut Code:
<cfmail to="#emailto#"
from="#ttMailTextQuery.EmailFrom#"
subject="#ttMailTextQuery.EmailSubject#"
server="#MailServer#">
<cfmailparam name="MIME-Version" value="1.0">
<cfmailparam name="Content-Type" value="multipart/alternative;
boundary=#chr(34)##mimeBoundary##chr(34)#">
<cfmailparam name="Content-Transfer-Encoding" value="7bit">
This is a Multipart MIME message.

--#mimeBoundary#
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

#TagEmailBodyPlain#

--#mimeBoundary#
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

#TagEmailBodyHTML#

--#mimeBoundary#--
</cfmail>


If you have a version of CF prior to the CFMAILPARAM tag you can try adding extra x-mailer headers in via carriage returns and the subject:

<cfset mimeBoundary = "foobar">
<cfset customHeader = "MIME-Version: 1.0"&Chr(13)&Chr(10)&"Content-Type:
multipart/alternative; boundary="&chr(34)&mimeBoundary&chr(34)>
<cfset hijackedHeader = Attributes.subject&Chr(13)&Chr(10)&customHeader>
<cfmail to="#Attributes.to#" from="#Attributes.from#"
subject="#hijackedHeader#">