CDONTS in Loop Issue 2008 server

129 Views Asked by At

I have the following CDONTS code that works fine:

Dim CDONTSMail 
Set CDONTSMail = CreateObject("CDONTS.NewMail") 
CDONTSMail.From= "[email protected]" 
CDONTSMail.To= "[email protected]" 
CDONTSMail.Subject= "500.100 Error: " & objASPError.File 
strBody = "This is a test message." & vbCrLf 
CDONTSMail.Body= sErrorMes 
CDONTSMail.Send 
set CDONTSMail=nothing 

However the following when used in a loop errors out? any ideas?

'Create Mailer object and send message

CDONTSMail.From= "[email protected]" 
CDONTSMail.To = Session("Email") 
CDONTSMail.Subject = Subject 
strBody = MainMessage & vbCrLf
CDONTSMail.Body= strBody 
CDONTSMail.Send 
1

There are 1 best solutions below

0
On BEST ANSWER

You need to set CDONTSMail again.

Try this in your loop:

Set CDONTSMail = CreateObject("CDONTS.NewMail") 
CDONTSMail.From= "[email protected]" 
CDONTSMail.To= "[email protected]" 
CDONTSMail.Subject = Subject 
strBody = MainMessage & vbCrLf
CDONTSMail.Body= strBody 
CDONTSMail.Send 
set CDONTSMail=nothing