Customizing e-mail for multiple recipients
I have a small app that allows a user to enter a message along with some fields to be personalized. So, when the email comes through it will say "Dear John Doe, Thanks for purchasing our Fitness book", etc. The problem I'm running into is personalizing the content. I can only get it to pull the first record from the recordset, instead of all of them. In other words, if the email goes out to 10 people, all 10 of them get the first and last name associated with the first record.
This is what my code looks like:
<cfoutput query="getFields">
<cfscript>
variables.content = ReplaceNoCase(variables.content, "*"&column_name&"*", evaluate("getCustomers."&column_name), "ALL");
</cfscript>
</cfoutput>
<cfmail from="#attributes.from_address#" to="#trim(emailaddress)#" subject="#attributes.title#" query="getCustomers" type="HTML">
#variables.content#
</cfmail>
This is what the source of the email looks like:
Dear *fname* *lname*, Thanks for purchasing our *bookTitle*
How can I make cfmail merge each row's value? Am I forced to loop over the recordset and call cfmail each time? This seems really inefficient.
TIA
