<!--#include file="conn.asp"-->
<!--#INCLUDE FILE="inc/sendmail.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if
%>
<title>给会员发邮件</title>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class=table-zuoyou BGCOLOR="#f1f1f1">

     <tr BGCOLOR="#ffffff" height="28"> 
    <td  width="20%" style="PADDING-LEFT: 6px">
        <b>邮件群发</b>

      </td>
          </tr>

  <tr BGCOLOR="#ffffff" height="28"> 
    <td valign="top" width="20%" style="PADDING-LEFT: 6px">
<%
dim userid,action,emailserver,emailuser,emailpassword,emailsign,emailComponent
userid=SafeRequest("id",1)
if userid="" then userid=request.form("userid")
action=Request.Form("action")
set rsstp=server.CreateObject("adodb.recordset")
rsstp.Open "select * from config",conn,1,1
emailserver=trim(rsstp("webbj7"))
emailuser=trim(rsstp("webbj8"))
emailpassword=trim(rsstp("webbj9"))
emailsign=trim(rsstp("webbj3"))
emailComponent=trim(rsstp("webbj4"))
emailcontent=trim(rsstp("webimg12"))
emailtitle=trim(rsstp("webbj14"))
rsstp.Close
set rsstp=nothing
%>
<%
select case action

case "send"

emailtitle=emailtitle
message=emailcontent
MailType = emailComponent
smtpserver = emailserver
sendusername = emailuser
sendpassword = emailpassword
SendName = emailsign

SendFrom = emailuser
subject=emailtitle
%>
<%

Select Case MailType
Case "Nothing"


Case "CDONTS"
set rs=server.createobject("adodb.recordset")
rs.open "select useremail from dv_user where userid in ("&userid&") order by userid desc " ,conn,1,1
if rs.eof And rs.bof then
Response.Write "<p align='center'> 对不起，没有用户邮件！</p>"
else



enumber=0
do while not rs.EOF

SendTO = rs("useremail")
call sendemail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message)

 enumber=enumber+1
%>
<script   language="Javascrpt">setTimeout("location.reload()",1000);</script>

 <%
response.write"发送成功"&enumber&"个邮件"&rs("useremail")&"<br>"

rs.MoveNext
loop
end if
rs.close
set rs=nothing 
%>
<%
Case "Jmail"
set rs=server.createobject("adodb.recordset")
rs.open "select useremail from dv_user where userid in ("&userid&") order by userid desc " ,conn,1,1
if rs.eof And rs.bof then
Response.Write "<p align='center'> 对不起，没有用户邮件！</p>"
else
enumber=0
do while not rs.EOF
SendTO = rs("useremail")
call SendJmail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message,SendName)
 enumber=enumber+1


%>

<script   language="Javascrpt">setTimeout("location.reload()",360000);</script>
<%  
response.write"发送成功"&enumber&"个邮件"&rs("useremail")&"<br>"

rs.MoveNext
loop
end if
rs.close
set rs=nothing 
response.write "总共发送成功"&enumber&"个邮件"
%>

<%  
end select

%>




</td>
          </tr>
		 
        </table>

	

      


<% 
case ""
end select
 %>

<%

conn.close
set conn = nothing
%>