<%
option explicit
response.buffer= True
Server.ScriptTimeOut=99999999
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>生成问题</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FF9999"><br>
<br><br>
<br>
<table width="460" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">
  <tr bgcolor="#ff6666">
    <td width="91" align="center" bgcolor="#ff6666" id="crhtml"></td>
    <td width="366">
<img src="images/bar.gif" width=0 height=16 id=bar name=bar align=absmiddle>
</td>
  </tr>
  <tr align="center" bgcolor="#ff6666">
    <td colspan="2"><span id="percent">0</span>%</td>
  </tr>
</table>
</body>
</html>

<!--#include file="../config.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="chklogin.asp"-->
<!--#include file="../conn.asp"-->
<%
dim myemail,topic,mailbody,isgo
topic = request.Form("topic") '邮件标题
mailbody=HTMLcode(request.Form("mailbody")) '邮件内容

dim rs,sql
set rs=server.CreateObject("adodb.recordset")
sql="select usermail from kw_user"
rs.open sql,conn,1,1

for i=1 to rs.recordcount
myemail=rs(0)
	
set jmail= server.CreateObject ("jmail.message")
jmail.Silent = true
jmail.Charset = "gb2312"
JMail.ContentType = "text/html"
jmail.From = mailform
jmail.FromName = sendname
jmail.ReplyTo = mailform
jmail.Subject = topic
jmail.AddRecipient myemail
jmail.Body = mailbody 
jmail.MailServerUserName = mailname
jmail.MailServerPassWord = mailpass


isgo=jmail.Send(mailsmtp)
if isgo then
response.write "<script language=javascript>alert('邮件发送成功！');history.go(-1);</script>"
else
response.write "<script language=javascript>alert('邮件发送失败！');history.go(-1);</script>"
end if

jmail.Close
set jmail = nothing
rs.movenext
	        RecordIndex = RecordIndex + 1
            Call Refresh()
			Call Pause()
next

rs.close
set rs=nothing

const pausetime=5  '生成文章的暂停时间(1~100)
Sub Pause()
	Dim i,lStep,iCount
	iCount=pausetime
	lStep=200000	
	If  Not IsNumeric(iCount) OR iCount=0 Then Exit Sub
	iCount=CLNG(iCount)
	If iCount>100 Then iCount=100
	For i=1 To iCount * lStep
	Next
End Sub

Sub Refresh()
    Response.Write "<script>" & vbCrLf
    Response.Write "crhtml.innerHTML=""正在生成"";" & vbCrLf
    If RecordNum > 0 Then
        Response.Write "bar.width="
        If Fix((RecordIndex / RecordNum) * 350) = 0 Then
            Response.Write "1;" & vbCrLf
        Else
            Response.Write Fix((RecordIndex / RecordNum) * 350) & ";" & vbCrLf
        End If
            Response.Write "percent.innerHTML=""" & FormatNumber(RecordIndex / RecordNum * 100, 2, -1) & """;" & vbCrLf
    End If
    Response.Write "</script>" & vbCrLf
    Response.Flush
End Sub
%>
