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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send both HTML and TEXT emails? 1

Status
Not open for further replies.

XxS87xX

Technical User
May 29, 2003
15
0
0
CZ
I've tried doing it this way, but sending to hotmail, nothing shows up and sending to my domain outlook account gives me the same thing. Nothing shows in the client!?
Any help greatly appreciated.

Here's my code(I've used &quot;[&quot; instead of &quot;<&quot; for tags):

[cfmail from=&quot;dfosbery@infinitygroup.com&quot;
to=&quot;dfosbery@infinitygroup.com&quot;
cc=&quot;dfosbery@hotmail.com&quot;
subject=&quot;newsletter test&quot;]
[cfmailparam name=&quot;Content-Type&quot; value='multipart/alternative; boundary=&quot;123MuLtIpArT BoUnDaRy&quot;']

--123MuLtIpArT BoUnDaRy
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit

this is the text body

--123MuLtIpArT BoUnDaRy
Content-Type: text/html; charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit


[body]

[td bgcolor=&quot;Silver&quot;]this is the HTML body[/td]
[/body]


--123MuLtIpArT BoUnDaRy--


[/cfmail]
 
The devil is in the details, unfortunately.

Extra spaces and carriage returns will kill a multi-part email faster than a T1.

You have, for example, extra spaces to the left of the
Code:
<CFPARAM>
tag. And extra spaces after your boundaries. You also have extra lines between the
Code:
<CFPARAM>
and the first boundary as well as extra lines between the last boundary and the closing
Code:
</CFMAIL>
tag. Also, the lines between the boundaries and the content must not contain any spaces or characters... just a carriage return. It looks like yours contain spaces (particularly the line between the HTML header and the HTML content). These all can contribute to your email client deciding that the message is not multi-part... even though you're setting it up as such.

Also, it's advised to include the standard
Code:
<html>
tags, etc, in your HTML content.

I would also recommend always using double-quotes to designate values of CF attributes, instead of the single quotes you use in the cfmailparam tag. You can include quotes in the value by escaping them (doubling them up).

And finally... I'm not sure a multi-word boundary specification is supported across the board. Better to make it a single word... and save yourself the headache by stuffing it into a CF variable, so you're always 100% assured that it's exactly the same everywhere.

So something like this:
Code:
<cfset mailboundary = &quot;123MuLtIpArT-BoUnDaRy&quot;>
cfmail from=&quot;dfosbery@infinitygroup.com&quot;
        to=&quot;dfosbery@infinitygroup.com&quot; 
        cc=&quot;dfosbery@hotmail.com&quot;
        subject=&quot;newsletter test&quot;>

<cfmailparam name=&quot;Content-Type&quot; value=&quot;multipart/alternative; boundary=&quot;&quot;#mailboundary#&quot;&quot;&quot;>
--#mailboundary#
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit

This is the text body

--#mailboundary#
Content-Type: text/html; charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit

	<html>
	<head>
	   <title>newsletter test</title>
	</head>
		
        <body>
        <table>
             <tr>
                <td bgcolor=&quot;Silver&quot;>this is the HTML body</td>
            </tr>
        </table>            
        </body>
	</html>

--#mailboundary#-- 
</cfmail>

I think the main offender in your case was the extra spaces you had in the blank lines between the header for each section and the content for the section. They should always be:
Code:
--myboundary
Code:
CRLF
Code:
Content-Type: text/html; charset=&quot;iso-8859-1&quot;
Code:
CRLF
Code:
Content-Transfer-Encoding: 8bit
Code:
CRLF
Code:
Code:
CRLF
Code:
My content
Code:
CRLF
Code:
--myboundary
Code:
CRLF
Code:
   :

You had:
Code:
--myboundary
Code:
CRLF
Code:
Content-Type: text/html; charset=&quot;iso-8859-1&quot;
Code:
CRLF
Code:
Content-Transfer-Encoding: 8bit
Code:
CRLF
Code:
Code:
space space space
Code:
CRLF
Code:
My content
Code:
CRLF
Code:
--myboundary
Code:
CRLF
Code:
   :

Like I said... the devil's in the details.




-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top