Im attempting to post this for the 4th time.  I tried to apply the solution
below and spent a couple hours on it but I can't seem to get it:  Code I am
using is below.  It has been cut down a bit to make it straight forward.  I
can sent the code as an attachment if needed as it seems as though proper
carriage returns count.  Any help on this would be greatly appreciated

<cfscript>
        from = "[EMAIL PROTECTED]";
        fromalias = "Brian";
        subject = "Test";
        plaintextbody = "Plain Test";
        htmlbody = "<html><head><title>Untitled</title></head><body><b>BOLD
TEST</b></body></html>";
</cfscript>


<cfif Len(htmlbody)>
        <CFSET MIMEBOUNDARY = "----MIME-BOUNDARY----">

        <!--- NO carriage returns in the next two variables --->
        <CFSET contenttype = "multipart/alternative;
boundary="""&MIMEBOUNDARY&"""">
        <CFSET myHeaders = "X-Mailer: CCC Mailer, MIME-Version: 1.0">

        <!--- MUST have carriage returns in the next two variables --->
        <CFSET myPlainMsgTop = "--#MIMEboundary#
        Content-Type: text/plain; charset=us-ascii
        Content-Transfer-Encoding: 7bit
        ">

        <CFSET myHTMLMsgTop = "--#MIMEboundary#
        Content-Type: text/html; charset=us-ascii
        Content-Transfer-Encoding: 7bit
        ">

<cfelse>
        <CFSET MIMEBOUNDARY = "">
        <CFSET contenttype = "text/plain">
        <CFSET myHeaders = "X-Mailer: CCC Mailer">
        <CFSET myPlainMsgTop = "">
        <CFSET myHTMLMsgTop = "">
</cfif>

<!--- Send the message --->
<CFMAIL To="[EMAIL PROTECTED]"
From='"#FromAlias#" <#from#>'
Subject="#Subject#
Content-type: #contenttype#
#myHeaders#">#myPlainMsgTop##plaintextbody#

#myHTMLMsgTop##htmlbody#
</cfmail>




-----
Thank you to everyone who responded to this, I received several different
ways to do this, and the solution we chose was provided by Ron Allen
Hornbaker, President/CTO, Humankind Systems, Inc., over on CF-Community...
(you guys should really sign up for the list...it's lots of fun over
there.....)

Here was his answer to the problem along with sample code that I am in the
process of testing and implementing. This is something worth marking for a
future look if you are dealing with clients who send out email newsletters
or any kind of marketing email.

----------------------------------------
Erika,

Them durned FloNetwork folks is usin' high-falutin' marketing-speak for a
very common type of email formatting: the multipart-alternative message.
We use it all the time, and so does Amazon, EggHead, and any other
big-time html email newsletter you've ever seen. We learned it by just
examining the headers of newsletters from Amazon, and it's really quite
simple. The receiving mail client will display the HTML version if it can,
and the plain-text version if it cannot. Remember: email is one of the
oldest 'net technologies around, and it's all just plain text (even
attachments). You can examine the full headers and text of messages quite
easily with most email clients.

Here's some CF code that will do it... it expects form imput like you see
in the cfparam's, and will create a multipart/alternative message if
you've provided an HTML body for the message in the form...

================================================================
<cfparam name="Form.from" default="">
<cfparam name="Form.fromalias" default="">
<cfparam name="Form.subject" default="">
<cfparam name="Form.plaintextbody" default="">
<cfparam name="Form.htmlbody" default="">

<cfquery name="Data" datasource="#DS#" username="#DSUsername#"
password="#DSPassword#">
...... your query here to get the recips firstname, email, etc. ...
</cfquery>


<cfif Len(form.htmlbody)>
<CFSET MIMEBOUNDARY = "----MIME-BOUNDARY----">
<!--- NO carriage returns in the next two variables --->
<CFSET contenttype = "multipart/alternative;
boundary="""&MIMEBOUNDARY&"""">
<CFSET myHeaders = "X-Mailer: ContestClicker Mailer, MIME-Version: 1.0">
<!--- MUST have carriage returns in the next two variables --->
<CFSET myPlainMsgTop = "--#MIMEboundary#
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

">
<CFSET myHTMLMsgTop = "--#MIMEboundary#
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

">
<cfelse>
<CFSET MIMEBOUNDARY = "">
<CFSET contenttype = "text/plain">
<CFSET myHeaders = "X-Mailer: ContestClicker Mailer">
<CFSET myPlainMsgTop = "">
<CFSET myHTMLMsgTop = "">
</cfif>

<cfloop query="Data">
<!--- Personalize the messages with data from the query --->
<cfset mySubject = Replace(form.subject,"%firstname%",firstname,"All")>
<cfset mySubject = Replace(mySubject,"%lastname%",lastname,"All")>
<cfset myPlainText =
Replace(form.plaintextbody,"%firstname%",firstname,"All")>
<cfset myPlainText = Replace(myPlainText,"%lastname%",lastname,"All")>
<cfset myHTMLText = Replace(form.htmlbody,"%firstname%",firstname,"All")>
<cfset myHTMLText = Replace(myHTMLText,"%lastname%",lastname,"All")>
<cfset myHTMLText = Replace(myHTMLText,"%email%",emailaddr,"All")>

<!--- Send the messages --->
<CFMAIL To="#emailaddr#"
From='"#Form.FromAlias#" <#form.from#>'
Server="206.57.37.74"
Subject="#mySubject#
Content-type: #contenttype#
#myHeaders#">#myPlainMsgTop##myPlainText#

#myHTMLMsgTop##myHTMLText#
</cfmail>
</cfloop>






Done!


==================================================================

The carriage returns, especially after the first and second lines of the
message Subject, are very important... that's how you set custom headers
(like Content-Type: multipart/alternative, etc.) with the <CFMAIL> tag.
The MIME-BOUNDARY can be set to just about any string that's unique.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to