Hi John,
Use <cfloop /> or the query attribute in cfmail but not both.
ie
<!---send emails--->
<cfquery datasource="my_DSN" name="GetUsers">
select emailaddress, firstname
from emails
</cfquery>
<cfloop query="GetUsers">
<cfmail to="#GetUsers.emailaddress#"
from="[email protected]"
subject="Hello From Got Nutrients?"
type="HTML">
Dear #GetUsers.firstname#<br />
We, here at Got Nutrients?, would like to thank you for joining.<br
/>
Best wishes
John
</cfmail>
</cfloop>
Or
<cfmail to="#GetUsers.emailaddress#"
from="[email protected]"
subject="Hello From Got Nutrients?"
type="HTML" query="GetUsers">
Dear #GetUsers.firstname#<br />
We, here at Got Nutrients?, would like to thank you for joining.<br
/>
Best wishes
John
</cfmail>
<cfmail /> with query is less code but always looks to me likes its sending
just a single email so I use the <cfloop method>
Paul.
-----Original Message-----
From: John Barrett [mailto:[email protected]]
Sent: Wednesday, 21 January 2009 2:24 AM
To: cf-newbie
Subject: cfmail& query users
Did I do something really wrong here?
I am using cfmail to query a database to send a welcome mail for users in
the database. Instead of looping through the database, it takes the first
filed and sends that for the number of users in there. There are 3 so if I
run the code I get 3 mails in one account,and not the one in the 3 mail
accounts.
<!---send emails--->
<cfquery datasource="my_DSN" name="GetUsers">
select emailaddress, firstname
from emails
</cfquery>
<cfloop query="GetUsers">
<cfmail to="#emailaddress#"
from="[email protected]"
subject="Hello From Got Nutrients?"
type="HTML"
query="GetUsers">
Dear #GetUsers.firstname#<br />
We, here at Got Nutrients?, would like to thank you for joining.<br
/>
Best wishes
John
</cfmail>
</cfloop>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4305
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15