Forum Moderators: open
1) set a variable to the current time + 7 seconds
2) set up a while loop to run and do nothing until the current time is greater than the variable value.
There are probably much better ways to do this, but I don't know what language you're using.
Dim strSQL
strSQL = "SELECT *, CustomerID AS Expr1, Name AS Expr2, Email AS Expr3, Test AS Expr4 FROM mailtest;"
objRS.Open strSQL, objConn
'Loop until we've hit the EOF (end of file)
Do Until objRS.EOF = True
'Set up the email object
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
With objMail
.From = "Admin Email"
.To = objRS("Email")
.Subject = ("subject")
.BodyFormat = 0 'CdoBodyFormatHTML
.MailFormat = 0 'CdoMailFormatMime
.Body = strHTML
.Send
Response.Write "Name = " & objRS("Name")
Response.Write "<BR>Email = " & objRS("Email")
Response.Write "<BR>Your e-mail has been sent. <BR><BR>"
Response.Write "<P><HR><P>"
End With
Set objMail = Nothing
'Move to the next record (important!)
objRS.MoveNext
Loop
what do i need to do?
---
Dim strSQL
strSQL = "SELECT *, CustomerID AS Expr1, Name AS Expr2, Email AS Expr3, Test AS Expr4 FROM mailtest;"
objRS.Open strSQL, objConn
'Loop until we've hit the EOF (end of file)
Do Until objRS.EOF = True
'Set up the email object
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
With objMail
.From = "Admin Email"
.To = objRS("Email")
.Subject = ("subject")
.BodyFormat = 0 'CdoBodyFormatHTML
.MailFormat = 0 'CdoMailFormatMime
.Body = strHTML
.Send
Response.Write "Name = " & objRS("Name")
Response.Write "<BR>Email = " & objRS("Email")
Response.Write "<BR>Your e-mail has been sent. <BR><BR>"
Response.Write "<P><HR><P>"
End With
Set objMail = Nothing
'Move to the next record (important!)
objRS.MoveNext
EndTime = Now() + (7 / (24 * 60* 60)) '7 seconds
Do While Now() < EndTime
'Do nothing
Loop
Loop
-----
This will, in all likelyhood, cause your page to time out on running it, as ASP has to render ALL of it's scripting before the page displays.
If it's vital that this run from the web : [support.microsoft.com...]
will show you how to change timeouts.
Probably not the best solution, still, but it's the only way I can think of to do this in ASP
'Move to the next record (important!)
objRS.MoveNext
EndTime = Now() + (7 / (24 * 60* 60)) '7 seconds
Do While Now() < EndTime
'Do nothing
Loop
Loop
the time piece being before the obj.rs.MoveNext?
Lets you queue emails to be sent by a service outside of IIS, so the ASP scripts don't have to hang - just add to the queue and tell it what time to send.
Mailer.QMessage = true
Mailer.QTime = "07/30/00 22:10:00"
objRS.Open strSQL, objConn
'Loop until we've hit the EOF (end of file)
Do Until objRS.EOF = True
Bla,bla
Response.Write "Name = " & objRS("Name")
Response.Write "<BR>Email = " & objRS("Email")
Response.Write "<BR>Your e-mail has been sent. <BR><BR>"
Response.Write "<P><HR><P>"
End With
Set objMail = Nothing
'Move to the next record (important!)
objRS.MoveNext
EndTime = Now() + (7 / (24 * 60* 60)) '7 seconds
Do While Now() < EndTime
'Do nothing
Loop
Loop
'Close the Recordset object
objRS.Close
'Delete the Recordset Object
Set objRS = Nothing
'Close the Connection object
objConn.Close
'Delete the Connection Object
Set objConn = Nothing
%>
If you do something like this (as you posted above):
EndTime = Now() + (7 / (24 * 60* 60)) '7 seconds
Do While Now() < EndTime
'Do nothing
you'll be maxing out your CPU (and slowing down any other programs that are running) while waiting for the 7 seconds to pass.
Stevelibby:
Again, the queued mail system is a much better solution than the one I presented.
I don't think that it would run 3 times based on the code we've got here... might want to check your database and make sure that the entries aren't duplicated. Or to be completely sure, put the keyword "DISTINCT" in front of Email in your SQL