User Guide

Table Of Contents
Sample uses of the cfmail tag 979
Reviewing the code
The following table describes the code:
Sending e-mail to multiple recipients
In addition to simply using a comma-delimited list in the
to attribute of the cfmail tag, you can
send e-mail to multiple recipients by using the
query attribute of the cfmail tag. The following
examples show how you can send the same message to multiple recipients and how you can a
customize each message for the recipient.
Sending a simple message to multiple recipients
In the following example, a query (BetaTesters) retrieves a list of people who are beta testing
ColdFusion. This query then notifies each beta tester that a new release is available. The contents
of the
cfmail tag body are not dynamic. What is dynamic is the list of e-mail addresses to which
the message is sent. Using the variable
#TesterEMail#, which refers to the TesterEmail column
in the Betas table, in the
to attribute, enables the dynamic list:
<cfquery name="BetaTesters" datasource="myDSN">
SELECT * FROM BETAS
</cfquery>
<cfmail query="BetaTesters"
from="beta@MyCompany.com"
to="#BetaTesters.TesterEMail#"
subject="Widget Beta Four Available">
To all Widget beta testers:
Widget Beta Four is now available
for downloading from the MyCompany site.
The URL for the download is:
http://beta.mycompany.com
Regards,
Widget Technical Support
beta@MyCompany.com
</cfmail>
Code Description
<cfoutput>
#ProductRequests.FirstName#
#ProductRequests.LastName#
(#ProductRequests.Company#) -
#ProductRequests.EMailAddress#&##013;
</cfoutput>
Presents a dynamic list embedded within a normal
cfmail message, repeating for each row in the
ProductRequests query. Because the
cfmail tag
specifies a query, the
cfoutput tag does not use a
query attribute. The &##013; forces a carriage return
between output records.