Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_cdo thread: sending mail within a recordset loop


Message #1 by "David Hemingway" <david_hemingway@b...> on Fri, 14 Apr 2000 12:12:16
I am trying to build an e-mail sender that pulls email address from a 

database and builds an email in a loop until recordeset.eof. The procedure 

works for the first email address and then stops. Has anybody come across  

anything like this. The code for the loop is below



set Rs = server.createobject("ADODB.Recordset")        

        strRecipientsSQL = "SELECT * FROM autoResponder"

        Rs.Open strRecipientsSQL

         ' handle a db error

        'if err <> 0 then Call CustomErrorValue(9)

      '  If Rs.BOF and rs.eof then

           ' handle no records error

         'Call CustomErrorValue(7)

       ' else

           ' get all mail addresses from db 

    Do While NOT Rs.BOF AND NOT Rs.EOF

	Mailer.To = rs("emailaddress")

	Mailer.from = "info@i..."

	'get the subject subject

    Mailer.Subject = "topic"

	'get the body

    Mailer.Body = body & vbCrLf & vbCrLf & "You registered as " & 

rs("emailaddress") & vbCrLf & footer

	'send the mail	  

    Mailer.Send	  

    Rs.MoveNext

    LOOP 



Regards



David Hemingway

Message #2 by David Hemingway <DavidH@i...> on Fri, 14 Apr 2000 13:10:16 +0100
I've now sorted the problem, I needed to create the mail object and set it

to nothing within to loop. I hope somebody else can use the code



David Hemingway



	-----Original Message-----

	From:	David Hemingway 

	Sent:	14 April 2000 13:12

	To:	ASP CDO

	Subject:	[asp_cdo] sending mail within a recordset loop



	I am trying to build an e-mail sender that pulls email address from

a 

	database and builds an email in a loop until recordeset.eof. The

procedure 

	works for the first email address and then stops. Has anybody come

across  

	anything like this. The code for the loop is below



	set Rs = server.createobject("ADODB.Recordset")        

	        strRecipientsSQL = "SELECT * FROM autoResponder"

	        Rs.Open strRecipientsSQL

	         ' handle a db error

	        'if err <> 0 then Call CustomErrorValue(9)

	      '  If Rs.BOF and rs.eof then

	           ' handle no records error

	         'Call CustomErrorValue(7)

	       ' else

	           ' get all mail addresses from db 

	    Do While NOT Rs.BOF AND NOT Rs.EOF

		Mailer.To = rs("emailaddress")

		Mailer.from = "info@i..."

		'get the subject subject

	    Mailer.Subject = "topic"

		'get the body

	    Mailer.Body = body & vbCrLf & vbCrLf & "You registered as " & 

	rs("emailaddress") & vbCrLf & footer

		'send the mail	  

	    Mailer.Send	  

	    Rs.MoveNext

	    LOOP 



	Regards



	David Hemingway



	---

	You are currently subscribed to asp_cdo 


$subst('Email.Unsub')


  Return to Index