
<object runat=server id=conn1 progid="adodb.connection"></object>
<%application.Lock
conn1.Open Application("p_jyzx")
Application.UnLock
%>
<% 
	
	 Server.ScriptTimeOut=10
if Request("flag")=1 then
	SMTPServer_username=Application("SMTPServer_username")
   SMTPServer_passwd=Application("SMTPServer_passwd")
	SMTPServer=Application("SMTPServer")
	SystemEmail=Application("SystemEmail")
	SenderName=Application("SenderName")
	topic=Request("topic")
	mailbody=Request("mailbody")
	
	dim msg,SendMail
	Set msg = Server.CreateObject("JMail.Message")
		msg.silent = true
		msg.Logging = true
		msg.Charset = "gb2312"
		msg.MailServerUserName = SMTPServer_username
		msg.MailServerPassword = SMTPServer_passwd
		msg.From = SystemEmail
		msg.FromName = SenderName
		msg.Subject = topic
		msg.Body = mailbody
		'msg.AddRecipient "domustdo@163.com","domustdo"
'/////////////////////////////////////////
	if Request("user_type")=0 then
		 sql="select email,user_name from user"
		
	elseif 	Request("user_type")=1 then
		sql="select email,user_name from user where weight=1"

	elseif 	Request("user_type")=2 then
		sql="select email,user_name from user  where weight=2"

	end if
		set rs=server.CreateObject ("ADODB.recordset")
     	   rs.Open sql,conn1,3,2
		rows=1
		while not rs.EOF 
		if rs("email")<>"" then
		if rows=1 then
		msg.AddRecipient rs("email"),rs("user_name")
		else
		msg.AddRecipientBCC rs("email"),rs("user_name")
		end if
		rows=rows+1
		end if
		rs.MoveNext 
		wend
		msg.Send (SMTPServer)
		set msg=nothing
	'//////////////////////////////////////////////
		
		
	
		
	if err then 
	SendMail=err.description
	err.clear
	else
	SendMail="成功！"
	end if
	'end sub
  
  
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY><LINK 
href="css/default.css" rel=stylesheet>

<p align=center><BR><BR><BR><BR>邮件发送<%=SendMail%>
	
</P>
<p align=center>系统已经将你的信件发送出去了！<%=rows%>
<p  align=center><font size=5><a href=mail_manage.asp>返回</font></a></p>
</P>
</FORM>
</BODY>
</HTML>
<%else%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgColor=#FFFBE7>
<LINK 
href="css/default.css" rel=stylesheet>
<BR>
<TABLE cellSpacing=0 width="100%" align=center bgColor=#FFFBE7 cellPadding=5>
        <TBODY bgColor=#FFFBE7>
        <TR>
		<TD align=center>发送群体邮件</TD>
		<TD><font size=5><a href=mail_manage.asp>返回</font></a></TD>
		</TR>
</tbody>
</table>	
<FORM action="mail_for_mass.asp" method=POST id=form1 name=form1>
<INPUT type="hidden" id=text1 name=flag value=1>
<TABLE cellSpacing=1 width="100%" align=center bgColor=#FFCC33 cellPadding=5>
        <TBODY bgColor=#FFFBE7>
        <TR>
		<TD>&nbsp;&nbsp;收信人：</TD>
		<TD>
		<SELECT id=select1 name="user_type" >

		<OPTION value="0" selected>所有会员</OPTION>
		<OPTION value="1" >所有普通会员</OPTION>
		<OPTION value="2" >所有VIP会员</OPTION>

		</SELECT>
		</TD>
	</TR>
	<TR>
		<TD>&nbsp;&nbsp;主题：</TD>
		<TD ><INPUT  class=input2 type="text" id=text2 name=topic  size=50></TD>
	</TR>
	<TR>
		<TD colspan=2 align=center>主体内容：</TD>
		
	</TR>
	<TR>
		
		<TD colspan=2 align=center><TEXTAREA  class=input2 rows=16 cols=80 id=textarea1 name=mailbody></TEXTAREA></TD>
	</TR>
	<TR align=center>
		<TD  align=center colspan=2><INPUT  class=input2 type="submit" value="发 送" id=submit1 name=submit1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<INPUT  class=input2 type="reset" value="取 消" id=reset1 name=reset1></TD>
	</TR>
</TABLE>

</FORM>
</BODY>
</HTML>
<%end if

%>