if Request.ServerVariables("REQUEST_METHOD") = "POST" then
strSubject = Request.Form("txtSubject")
strBody = Request.Form("txtBody")
strFrom = Request.Form("txtFrom")
' 从数据库拔取收件人纪录
strSQL_SelectEmail = "SELECT Guests.Guest_ID, Guests.Guest_Email " & _
" FROM Guests WHERE ((Guests.Mail_List)=-1);"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open strDSNPath
Set rsMail = oConn.Execute(strSQL_SelectEmail)
if rsMail.BOF = True and rsMail.EOF = True then
...数据库为空提醒,略...
else
rsMail.MoveFirst
Do While Not rsMail.EOF
' 创立对象
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
' 填写其它邮件题目信息
Mailer.FromName = strFrom
Mailer.FromAddress = strEmailFrom
Mailer.RemoteHost = strHost
Mailer.Subject = strSubject
Mailer.BodyText = ...设置邮件内容,略...
strTo = rsMail.Fields("Guest_Email").Value
If strTo < > "" then
Mailer.Recipient = strTo
if Mailer.SendMail then
...发送胜利提醒,略...
else
...发送掉败提醒,略...
end if 'Mailer.SendMail
end if 'strTo < > ""
rsMail.MoveNext
Set Mailer = Nothing
Loop
end if 'rsMail.BOF = True and rsMail.EOF = True
rsMail.Close
Set rsMail = Nothing
oConn.Close
Set oConn = Nothing
end if 'REQUEST_METHOD = "POST"