PDA

View Full Version : Retreiving multiple address for CDONTS


mgoldsmith
01-09-2003, 12:17 PM
I have a query that returns multiple emails addresses, and I want to send an email to all of them. When I put the code in to get the values from the recordset, put them in the "to" field, and send the mail, it only goes to the first result of the query. Any ideas on how I can get the email sent to all the addresses?
thanks

Max

email.to = Proj.fields.item("EMAIL").value

arnyinc
01-09-2003, 01:25 PM
You need to loop through your recordset to get all the addresses. Right now you're only sending it to the first record, so you have to build a string with all the records.

<%
Set RS=MyConn.execute("Select emailaddress from contacts")

recipients=""
WHILE NOT RS.EOF
recipients=RS("emailaddress")&";"&recipients
RS.MOVENEXT
WEND

email.to = recipients
%>

mgoldsmith
01-09-2003, 04:13 PM
that looks right, but the code crashes on the WEND part of the loop.

Proj.Open()
recipients=""
While not proj.EOF
recipients=proj("RLEMAIL")&";"&recipients
proj.movenext
WEND

the rest of my email code goes here......

mgoldsmith
01-09-2003, 04:15 PM
forgot to mention that this email is sent as part of an update action which is started when the form is submitted.