User Guide

Table Of Contents
Sample uses of the cfmail tag 977
Sending multipart mail messages
The
cfmailpart tag lets you create multipart mail messages, with each part having a different
MIME type or character set. For example, if you do not know that all recipients can interpret
HTML mail messages, you can send your message as a multipart mail with a text part and an
HTML part. To do so use two
cfmailpart tags, one with the HTML version of the message and
one with the plain text message, as shown in the following example. To test this example, replace
the
To attribute value with a valid email address, save and run the page, and check the incoming
email at the address you entered.
<cfmail from = "peter@domain.com" To = "paul@domain.com"
Subject = "Which version do you see?">
<cfmailpart
type="text"
wraptext="74">
You are reading this message as plain text, because your mail reader
does not handle HTML text.
</cfmailpart>>
<cfmailpart
type="html">
<h3>HTML Mail Message</h3>
<p>You are reading this message as <strong>HTML</strong>.</p>
<p>Your mail reader handles HTML text.</p>
</cfmailpart>
</cfmail>
Note: In the HTML version of the message, you must escape any number signs, such as those used
to specify colors, by using two # characters; for example,
bgcolor="##C5D9E5".
Sample uses of the cfmail tag
An application page containing the cfmail tag dynamically generates e-mail messages based on
the tag’s settings. The following sections show some of the tasks that you can accomplish with
cfmail:
Sending a mail message in which the data the user enters in an HTML form determine the
recipient and contents
Using a query to send a mail message to a database-driven list of recipients
Using a query to send a customized mail message, such as a billing statement, to a list of
recipients that is dynamically populated from a database
Later sections in this chapter show additional ways you can use the
cfmail tag to send e-mail
messages.