How Do I Send An Email To Multiple Recipients Without All Email Addresses Being Listed in the To Line?

Use the query attribute of the <cfmail> tag. Doing this will iterate once over the cfmail tag for each row in the query. You must specify the query column that contains the appropriate email address in the to attribute of cfmail.

<!--- query the database to find out who needs the email ---> <cfquery name="getEmailAddresses" dataSource="#theDSN#"> SELECT emailAddress FROM tblUsers </cfquery>
<!--- set up variables --->
<cfset variables.msg = "this is a test message"> <cfset variables.subject = "test subject"> <cfset variables.from = "me@ohMy.com"> <cfset variables.server= "mail.ohMy.com">
<cfmail
from="#variables.from#" subject="#variables.subject#" 
query="getEmailAddresses"
to="#emailAddress#"
server="#variables.server#">
#variables.msg#
</cfmail>

This question was written by Todd Sharp
It was last updated on July 7, 2008.

Categories

Email

Comments

comments powered by Disqus