Skip to main content
Known Participant
December 19, 2006
Question

cfmail loop query

  • December 19, 2006
  • 2 replies
  • 620 views
can some one help me with this query please

i have a cfmail running off a query


i want to be able to send mail to a list of recipietns from my database

the query below works but only sends emails to the first contact in the list

what can i do to my query to change this?

<CFQUERY datasource="#application.ds#" Name="GetSch">
SELECT cc.Code, gg.PlayerPhone, dd.Message, cc.Club_Abbrev
FROM appoint_table dd, SMS_Players_Table gg, SMS_Clubs_Table cc
WHERE ServerSMS <= #CreateODBCDateTime(Now())# AND dd.App_ClientID = gg.PlayerID AND dd.LoginID = cc.ClubID
AND ServerSMS <> ''
</cfquery>

<cfmail to = "craig_mac@bigutton.com.au" query="GetSch"
from = "test"
subject="">

to:#Code##PlayerPhone#
text:#Message#
from:#Club_Abbrev#
</cfmail>
This topic has been closed for replies.

2 replies

Inspiring
December 19, 2006
Do not use a query attribute in your cfmail tag. Put a cfloop in the part where you compose your mail body.

Alternatively, use cfsavecontent to build your mail body and stick the resulting variable into the tag. That's the method I use.
Inspiring
December 19, 2006
Your query does not look like it's selecting any email addresses.

Your cfmail tag has a constant in the to attribute and will probably crash since the from attribute does not have a valid email address as it's value.
Keith444Author
Known Participant
December 19, 2006
ok thank i just realised what i need

just to go to one email as the cfmail is at the min

but i need to loop through the mail output so it send 30 emails to the same email

with the different
to:#Code##PlayerPhone#
text:#Message#
from:#Club_Abbrev#

for each record retreved form the query