Try putting the cfmail inside a cfloop query="GetList" tag.
Ade
-----Original Message-----
From: sara hyde [mailto:[EMAIL PROTECTED]
Sent: 21 August 2004 17:26
To: CF-Talk
Subject: multiple emails using database query
I want to send an email for each email record from a table of
mailing list contacts in a database. At the moment only the first
email is being sent. Please can someone tell me where I'm going
wrong!
<BODY>
<CFIF IsDefined("FORM.Subject")>
<!--- Retrieve "mailing list" records from database --->
<CFQUERY DATASOURCE="#REQUEST.DataSource#" NAME="GetList">
SELECT FirstName, LastName, EMail
FROM Contacts
WHERE MailingList = 1
</CFQUERY>
<!--- Send the mail message, based on form input --->
<CFMAIL
QUERY="GetList"
SUBJECT="#Form.Subject#"
FROM="""us"" <[EMAIL PROTECTED]>"
TO="""#FirstName# #LastName#"" <#EMail#>"
>#FORM.MessageBody#
</CFMAIL>
<CFELSE>
<!--- Provide simple form for recipient and message --->
<CFFORM ACTION="" NAME="mailForm" METHOD="POST"
confirm('Are you sure? This message will be
sent to everyone on the mailing list. This is your last chance to
cancel the bulk mailing.')">
<TABLE CELLPADDING="2" CELLSPACING="2">
<!--- Table row: Input for email Subject --->
<TR>
<TH>Subject:</TH>
<TD>
<CFINPUT
TYPE="Text"
NAME="Subject"
REQUIRED="Yes"
SIZE="40"
MESSAGE="You must provide a subject for the email.">
</TD>
</TR>
<!--- Table row: Input for actual Message Text --->
<TR>
<TH>Your Message:</TH>
<TD>
<TEXTAREA
NAME="MessageBody"
COLS="30"
ROWS="5"></TEXTAREA>
</TD>
</TR>
<!--- Table row: Submit button to send message --->
<TR>
<TD></TD>
<TD>
<INPUT
TYPE="Submit"
VALUE="Send Message Now">
</TD>
</TR>
</TABLE>
</CFFORM>
</CFIF>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

