Ciao ho trovato questo codice invio massivo di email con la ricerca.
E' strano ma dà errore sulla riga "send" dopo che ha inviato la prima serie di msg email, sapete dirmi perchè?
codice:
Function Sleep(sec)
Dim Start:Start = Timer:While (Timer-Start<sec):Wend
End function
xSQL = " SELECT * FROM "
xSQL = xSQL & " tbl"
Set rec = server.CreateObject("ADODB.Recordset")
rec.Open xSQL, Cn
if not rec.eof then
Const cdoSendUsingMethod = _
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = _
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = _
"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
rec.MoveFirst()
Conta = 0
ListaDestinatari = ""
Do Until rec.eof
Do Until (Conta > 8) OR (rec.eof = true)
ListaDestinatari = ListaDestinatari & rec("email") & "; "
Conta = Conta + 1
rec.MoveNext()
Loop
'#### CREO LA MAIL
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mio.dominio.it"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.From = "mittente@mittente.it"
.To = ListaDestinatari
.Cc = "mittente@mittente.it"
.Subject = "Oggetto msg"
.HtmlBody = "messaggio di prova"
.Send
End With
Response.Write("Attendo 5 secondi...")
Response.Flush
Sleep 5
Response.Write("OK ===> ")
response.write "Email inviata a ===> "
response.write "" & ListaDestinatari & ""
response.write "
"
Conta = 0
ListaDestinatari = ""
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
Loop
end if
end if
rec.Close()
Set rec = Nothing
cn.Close()
Set cn = Nothing
%>