Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Text and HTML email broadcasts

Status
Not open for further replies.

greatcanada

Programmer
Oct 23, 2000
7
CA
Hello everyone,

I have an idea as to how to send both a text and html version of an email that I would like to broadcast.

Reference:




The problem is that email application do not seem to pick up the sections that I've divided using the boundary.

Here is a simplified version of my code:



<cfmail to=&quot;whoever@whoever.com&quot; from=&quot;whoever@whoever.com&quot; subject=&quot;Test Mime
MIME-Version: 1.0
Content-type: multipart/mixed;
boundary=gc0p4Jq0M2Yt08jU534c0p&quot;>

hello there

--gc0p4Jq0M2Yt08jU534c0p
Content-type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit


Plain text here only!


--gc0p4Jq0M2Yt08jU534c0p
Content-type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
<head>
<title>Hello test!</title>
</head>


<body bgcolor=&quot;F0F0F0&quot; text=&quot;000000&quot; link=&quot;000099&quot; alink=&quot;800000&quot; vlink=&quot;000066&quot;>

blah... blah ... <b>blah</b>..

</body>

</body>
</html>

--gc0p4Jq0M2Yt08jU534c0p


</cfmail>



Results:

Using my outlook, its only picking up the text version because it is the first one in the order. It should be an html page because it is an html capable page viewer.

So how can make it so that, if a user's email application can read html-based email, it will use that &quot;section&quot;?

I understand the MIME concept but just can't get it to work in CF?

Any ideas? Thank you.

Christopher
 
Hey GC,

I think I see your confusion. In the RFC, they show an example which looks like you used as the basis for your code. The three lines you have in your subject line are actually the subject line and two additional header fields. These header fields are sent by the mail programs and not something you can type into a subject line in either a client program or in the <cfmail> tag. In CF4.5, they added a <cfmailparam> tag which allows you to add custom header fields to mail messages and this is what I think you'll need. I've never tried this before so let me know if you have trouble but I think this will do what you want. If you don't have CF4.5, I don't think there's anyway to use the code you outlined.

<cfmail to=&quot;whoever@whoever.com&quot; from=&quot;whoever@whoever.com&quot; subject=&quot;Test&quot;>
<CFMAILPARAM NAME=&quot;MIME-Version&quot; VALUE=&quot;1.0&quot;>
<CFMAILPARAM NAME=&quot;Content-type&quot; VALUE=&quot;multipart/mixed; boundary=&quot;&quot;simple
boundary&quot;&quot;&quot;>

...body of message with boundary line....

</cfmail>

If this doesn't work, try adding a colon to the name attributes in the <cfmailparam> tags like this:

name=&quot;MIME-Version:&quot; & NAME=&quot;Content-type:&quot;

Let me know how it works,
GJ
 
Thanks GunJack!

I really appreciate the time you took to answer my query. I'll keep you informed.

cheers,

Christopher
 
This seems to work.... Thanks to everyone who contributed.

(list of credits:=============================================
<cfset crlf = chr(13)&chr(10)>


<!--- Send the messages --->
<CFMAIL To=&quot;someone@somwhere.com&quot; From=&quot;you@yoursite.com&quot; Subject=&quot;test 8-1&quot;>

<cfmailparam name=&quot;Content-type&quot; value='multipart/alternative;boundary=&quot;----MIME-BOUNDARY----&quot;'>
<cfmailparam name=&quot;MIME-Version&quot; value=&quot;1.0&quot;>



------MIME-BOUNDARY----#crlf#Content-Type: text/plain;
charset=us-ascii#crlf#Content-Transfer-Encoding: 7bit#crlf##crlf#
<!--- begin plain text version --->
Test

------MIME-BOUNDARY----#crlf#Content-Type: text/html;
charset=us-ascii#crlf#Content-Transfer-Encoding: 7bit#crlf##crlf#
<!--- begin html version --->
<h1>Test</h1>

<p>
<font color=red>
Test
</font>
</p>

</cfmail>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top