![]() ![]() ![]() |
An application page with the CFMAIL tag dynamically generates email messages based on the tag's settings. Some of the things you can accomplish with CFMAIL are:
The CFMAIL tag behaves like the CFOUTPUT tag. It shares some attributes used by CFOUTPUT - QUERY, GROUP, STARTROW, and MAXROWS - and it employs several mail-specific attributes to handle mail header information and MIME and HTML files.
See the CFML Language Reference for a more information.
In the example below, the contents of a customer inquiry form submittal are forwarded to the marketing department. Note that the same application page could also insert the customer inquiry into the database.
<CFMAIL FROM="#Form.EMailAddress#" TO="marketing@allaire.com" SUBJECT="Customer Inquiry"> A customer inquiry was posted to our Web site: Name: #Form.FirstName# #Form.LastName# Subject: #Form.Subject# #Form.InquiryText# </CFMAIL>
In the example below, a query ("ProductRequests") is run to retrieve a list of the customers who have inquired about a product over the last seven days. This list is then sent, with an appropriate header and footer, to the marketing department:
<CFMAIL QUERY="ProductRequests" FROM="webmaster@allaire.com" TO="marketing@allaire.com" SUBJECT="ColdFusion status report"> Here is a list of people who have inquired about Allaire ColdFusion over the last seven days: <CFOUTPUT> #ProductRequests.FirstName# #ProductRequests.LastName# (#ProductRequests.Company#) - #ProductRequests.EMailAddress# </CFOUTPUT> Regards, The WebMaster webmaster@allaire.com </CFMAIL>
Note the use of the nested CFOUTPUT tag to present a dynamic list embedded within a normal CFMAIL message. The text within the CFOUTPUT is repeated for each row in the "ProductRequests" query, while the text above and below it serve as the header and footer (respectively) for the mail message.
The GROUP attribute specifies the query column to use when you group sets of records together to send as a single email message. For example, if you send a set of billing statements out to your customers, you might group them on "Customer_ID." The GROUP attribute, which is case sensitive, eliminates adjacent duplicates in the case where the data is sorted by the specified field.
In the following example, a query ("CFBetaTesters") is run to retrieve a list of people who are beta testing ColdFusion. This query is then used to send a notification to each of these testers that a new version of the beta release is available:
<CFMAIL QUERY="CFBetaTesters" FROM="beta@allaire.com" TO="#TesterEMail#" SUBJECT="ColdFusion Beta Four Available"> To all ColdFusion beta testers: ColdFusion Beta Four is now available for downloading from the Allaire site.The URL for the download is: http://beta.allaire.com Regards, ColdFusion Technical Support beta@allaire.com </CFMAIL>
Note that in this example, the contents of the CFMAIL tag are not dynamic, that is, they don't use any # delimited dynamic parameters. What is dynamic is the list of email addresses to which the message is sent. Note the use of the "TesterEMail" column from the "CFBetaTesters" query in the TO attribute.
![]() ![]() ![]() |
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.