效率是慢了点,但是绝对可以发送很多的邮件.
mailtest.asp
<%response.charset="gb2312"%>
<script>
function createXMLHttpRequest() {
if (window.XMLHttpRequest) {//Mozilla
xmlHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {//IE
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}
function SendMail(){
createXMLHttpRequest();
xmlHttp.open("get","sendmail.asp?fresh="+Math.random(),true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState==4){
document.getElementById("span1").innerHTML=xmlHttp.responseText;
}
else{
//document.getElementById("span1").innerHTML="<span style='color:#FF0000'>邮件正在发送中...</span>"
}
}
xmlHttp.send(null);
window.setTimeout("SendMail()",5000);
}
</script>
<script src="js/prototype.js"></script>
<body onload=window.setTimeout("SendMail()",5000)>
<span id="span1"></span>
sendmail.asp
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "Select top 10 *from userinfo where flag=false order by userid asc",cn,1,2
if not rs.eof then
mailaddress=rs("email")
%>
<%
response.charset="gb2312"
Set Jmail = Server.CreateObject("Jmail.Message")
Jmail.charset="gb2312"
jmail.contenttype="text/html"
Jmail.AddRecipient mailaddress
Jmail.From = "test115@163.com"
Jmail.Subject = "群发邮件"
Jmail.Body =""
Jmail.send("test115:******@smtp.163.com")
Jmail.Close
response.write ""
rs("flag")=true
rs.update
set rs=server.CreateObject("adodb.recordset")
rs.open "Select *from userinfo where flag=true",cn,1,2
cnt=rs.recordcount
response.write "邮件正在发送中...,已经发送"&"<span style='color:#FF0000'>"&cnt&"</span>"&"封"
else
response.write "邮件发送成功"
end if
%>