I looked at a number of examples, and came up w/this (it works under NT4
and CF4.5):


<cfset boundary = CreateUUID()>
<cfmail to="#email#" from="#emp_email1#" subject="#trim(content.x1)#">
<cfmailparam name="MIME-Version" value="1.0">
<cfmailparam name="Content-type" value="multipart/alternative; 
boundary=""#boundary#""">
<!--- DO NOT INDENT --->
--#boundary#
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

TEXT HERE

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

HTML HERE

--#boundary#--
<!--- DO NOT INDENT --->
</cfmail>



HTH,
Phil






"Woods, John (BA)" <[EMAIL PROTECTED]>@dfwcfug.org on
10/24/2001 11:20:53 AM

Please respond to [EMAIL PROTECTED]

Sent by:  [EMAIL PROTECTED]


To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:

Subject:  CFMAIL and multipart/alternative for plain text AND html



All,

I am trying to create an e-mail that will send both HTML and plain text
message using the multipart/alternative code that Seth provided (I have
attached it at the bottom of this message).  I am generating the message on
a Windows 2000 server with ColdFusion 5 Pro.  The mail server is Exchange
2000.

The problem that I am experiencing is when ColdFusion writes the file to
the
spool directory, it has the correct information in it (a different message
for plain text and for HTML text) as I expect.  However, when the message
gets sent and I look at it through a mail reader (both HTML and plain
text),
the message I sent in the plain text section gets replaced with the text
from the HTML section.  I am including my code and output here as well...

=======My Code=======
 <!--- Create a unique ID for the message boundary. --->
<cfset boundary = CreateUUID()>
<!--- Standard CFMAIL.. Note that the TYPE attribute is not set. --->
<cfmail to="[EMAIL PROTECTED]" from="[EMAIL PROTECTED]" subject="test">
<cfmailparam name="Content-Type" value="multipart/alternative;
boundary=""#boundary#""">
--#boundary#
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is the plain text message for the email.  HTML readers will not see
this.  That is all.
End of message

--#boundary#
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
     <title>HTML Message</title>
</head>
<body>
This is the <font size="+2" color="##FF0000">HTML text message</font> for
the email. This will not be seen with a plain text reader.
</body>
</html>
--#boundary#--
</cfmail>
=======Output of message sent (using a plain text reader)=======
> --------------InterScan_NT_MIME_Boundary
> Content-type: multipart/alternative;
>    boundary="8F306676-1B35-48DD-A3F3DE48F4CDAA7A"
>
> --8F306676-1B35-48DD-A3F3DE48F4CDAA7A
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: 8bit
>
> This is the HTML text message for the email. This will not be seen with
> a plain text reader.
>
> --8F306676-1B35-48DD-A3F3DE48F4CDAA7A
> Content-Type: text/html;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <html>
> <head>
>    <title>HTML Message</title>
> </head>
> <body>
> This is the HTML text message for the email. This will not be seen with =
> a plain text reader.
> </body>
> </html>
> --8F306676-1B35-48DD-A3F3DE48F4CDAA7A--
>
> --------------InterScan_NT_MIME_Boundary--



=======Seth's code=======

<!--- Create a unique ID for the message boundary. --->
<cfset boundary = CreateUUID()>
<!--- Standard CFMAIL.. Note that the TYPE attribute is not set. --->
<cfmail to="[EMAIL PROTECTED]" from="[EMAIL PROTECTED]" subject="test">
<!--- This message is going to be a multipart message.  Since an email is
really just a really long string of text, we need a unique substring to use
as a seperator between the parts.  Just to make sure that a seperator
doesn't accidentally get typed in, I like to use a UUID - the odds of this
exact string accidentally coming through in an email would be extremely
rare.  The mailparam tag will insert the value of the seperator into the
mail header, as well as telling the email client that this message is
composed of more than one part. --->
<cfmailparam name="Content-Type" value="multipart/alternative;
boundary=""#boundary#""">
<!--- Boundaries are always preceded by "--".  Each part of a multi-part
message is preceded by a boundary.  The boundary value MUST match the value
set in the header. --->
--#boundary#
<!--- Each section of the email gets it's own mini-header.  This header
tells the mail client what kind of data follows (plain text, 8 bit, in this
case), and is always seperated from the content that follows by one empty
line. --->
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is the plain text message for the email.
<!--- Every section gets a header, and every header begins with the same
exact Boundary value.  --->
--#boundary#
<!--- Modern mail clients that support HTML email will ignore a plain text
section of an email if there is also an HTML section.  Note the empty line
between the secion header and the content that follows it. --->
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!--- HTML formatted emails should generally be treated the same as html
pages.  Javascript is not allowed, however. The "title" tags are not
supported in most mail readers, but should be used anyway. --->
<html>
<head>
     <title>HTML Message</title>
</head>
<body>
This is the HTML text message for the email.
</body>
</html>
<!--- the final boundary is always followed by two hyphens.  This is how
the
email client knows that the message is complete, and not to expect another
section. --->
--#boundary#--
</cfmail>


-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org





This transmission may contain information that is privileged, confidential and/or 
exempt from disclosure under applicable law. If you are not the intended recipient, 
you are hereby notified that any disclosure, copying, distribution, or use of the 
information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. 
If you received this transmission in error, please immediately contact the sender and 
destroy the material in its entirety, whether in electronic or hard copy format. Thank 
you.


-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to