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="[email protected]"
   to="[email protected]"
   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
[email protected]

</cfmail>

Reviewing the code

The following table describes the code:

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.


View comments in LiveDocs