User Guide

Table Of Contents
978 Chapter 39: Sending and Receiving E-Mail
Sending form-based e-mail
In the following example, the contents of a customer inquiry form submittal are forwarded to the
marketing department. You could also use the same application page to insert the customer
inquiry into the database. You include the following code on your form so that it executes when
users enter their information and submit the form:
<cfmail
from="#Form.EMailAddress#"
to="marketing@MyCompany.com,sales@MyCompany.com"
subject="Customer Inquiry">
A customer inquiry was posted to our web site:
Name: #Form.FirstName# #Form.LastName#
Subject: #Form.Subject#
#Form.InquiryText#
</cfmail>
Sending query-based e-mail
In the following example, a query (ProductRequests) retrieves a list of the customers who inquired
about a product during the previous seven days. ColdFusion sends the list, with an appropriate
header and footer, to the marketing department:
<cfmail
query="ProductRequests"
from="webmaster@MyCompany.com"
to="marketing@MyCompany.com"
subject="Widget status report">
Here is a list of people who have inquired about
MyCompany Widgets during the previous seven days:
<cfoutput>
#ProductRequests.FirstName# #ProductRequests.LastName#
(#ProductRequests.Company#) - #ProductRequests.EMailAddress#&##013;
</cfoutput>
Regards,
The WebMaster
webmaster@MyCompany.com
</cfmail>