I wrote an asp page that send to my newsletter members a monthly update
Actually the DB contains 200 records
If I send the newsletter as is the asp page doens't terminate with the
final status message but stay in a working status
Anyway the newsletter seems to have been sent
So I tried with a new version that paginate the db records but I can
just send the first "n" records...
Can you please give me an hand? Where I'm wrong?
Here comes the code... thanks so much
<%@LANGUAGE = VBScript%>
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<html>
<head>
<title>Sending newsletter</title>
</head>
<body>
<h2>Invio Newsletter SentiCheStoria</h2>
<%
Dim pag, cn, rs, quante, tot, i
' check and store current page
pag = Request.QueryString("pag")
If IsNumeric(pag) = False Or pag < 1 Then pag = 1
%>
<p>
<form action="newsletter-test.asp" method="post" name="send_newsletter">
<strong>oggetto:</strong> <input type="text"
name="oggetto" size="50"><br /><br />
<strong>file:</strong> <input type="text"
name="nome_file" size="20"><br /><br />
<input type=submit name="Send" value="Send">
</form>
</p>
<%
Dim oggetto_newsletter, nome_file, sUrl
oggetto_newsletter = Request.Form("oggetto")
nome_file = Request.Form("nome_file")
sUrl = "http://www.mysite.it/newsletter/" & nome_file
If oggetto_newsletter <> "" Then
Session("oggetto_newsletter") = oggetto_newsletter
Else
Response.End
End If
If nome_file <> "" Then
Session("nome_file") = nome_file
Else
Response.End
End If
If sUrl <> "" Then
Session("sUrl") = sUrl
Else
Response.End
End If
' Mi connetto al database
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("db.mdb")
' Lancio la query
rs.Open "SELECT email FROM table WHERE attivo=Yes", cn, 1
' pagination
quante = 50
rs.CacheSize = quante
rs.PageSize = quante
rs.AbsolutePage = pag
tot = CInt(rs.PageCount)
i = 0
DIM Flds, iConf
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "smtp.mysite.it"
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPAuthenticate) = cdoBasic
Flds(cdoSendUserName) = "my-email-address"
Flds(cdoSendPassword) = "password"
Flds.Update
' sending email
Do While Not rs.EOF
Set email = Server.CreateObject("CDO.Message")
email.From = "My Address"
email.To = rs("email")
email.Subject = Session("oggetto_newsletter")
email.CreateMHTMLBody Session("sUrl")
email.Send
Set email = Nothing
i = i + 1
If i = quante Then Exit Do
rs.MoveNext
Loop
' cleaning
rs.Close
Set rs = Nothing
Set cn = Nothing
' go to next page
If CInt(pag) < CInt(tot) Then
Response.redirect "newsletter-test.asp?pag=" & CInt(pag) + 1
End If
%>
<hr><%= ("Current page: " & pag) %><hr>
</body>
</html>
> This sounds really complicated. Using a dedicated (or even shared)
> email smtp service for your newsletter will save you a lot of pain.
There is nothing complicated.
In fact there is nothing at all.
[please always quote on usenet]
> Try http://www.smtp.com/dedicated -- it works great for me!
No, I won't. Your posting could be spam.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)