How can I send mail to multiple recipients?

Created by Rainer Gerhards.

We are trying out your SimpleMail utility with ASP and are wondering what the easiest way to do multiple recipients would be.

Answer from Adiscon: I have attached a code snippet take from one of our real life applicatons. Before executing this code, an ADO result set is created. This result set is then (see the snippet) used to send email to multiple recipients. The basic idea is to call SimpleMail multiple times inside a loop. Please note that - contrary to this example which was created with a special transactional version of SimpleMail - it is sufficient to set the properties only once. Only modify the recipient inside the loop and call Send().


' Resultset rs already created!
Zaehler = 0
set o = Server.CreateObject("ADISCON.SimpleMail.1") ' create mailer!

response.write ("<table border=""1"">")
do while not rs.eof
 ' Now write Mail message 
 on error resume next
 o.MailServer = "127.0.0.1"
 o.Sender = "Info@Adiscon.com"
 o.Recipient = rs("EMail")
 o.Subject = Request("txtBetreff")
 o.MessageText = Request("txtMailText")
 call o.Send
 Zaehler = Zaehler + 1
 rs.movenext
loop
rs.close
 

 

Back to Non-Printer Version