<!--#INCLUDE FILE="setup.asp" -->
<!--#include file=checkuser.asp-->
<!--#include file=include/email.asp-->
<%Server.ScriptTimeOut=99999%>
<title><%=StrVar(1)%>--管理页面</title>
<link href="css.asp" rel="stylesheet" type="text/css">
<!--#include file=theme.css-->
<body class=adminbody>
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=superindex.asp target=_top>登陆</a>后进入。"
	Call Error("Information",ErrMsg)
Else
	Call main()
End if

Call endconnection()


Sub main()
%>
<table cellpadding=5 cellspacing=1 border=0 width=100% Class=TableBorder align=center>
<tr>
	<th>欢迎<b><%=membername%></b>进入管理页面</th>
</tr>
</table>
		<%if Request("action")="send" Then
			Call sendmail()
		Else
			Call mailform()
		End if
		
End Sub


Sub mailform()
%>

<center>
<table border=0 width=600><tr><td class=mp><BR><B><a name=top>说明</a></B>：当同学录中有大量的注册用户时，如果邮件收件人选择"所有注册用户"，将消耗大量的服务器资源。<br>
</td></tr></table>

<BR>
<form method="POST" action=sysadm_mailist.asp>
<input type=hidden name=Action value="send">
<table width="600" border="0" cellspacing="1" cellpadding="5"  align=center Class=TableBorder>
<tr> 
<th height="11" colspan="2" ><b>同学录邮件列表</b></font></th>
</tr>
<tr  Class=LightTableBody> 
<td width="25%" height="18">&nbsp;&nbsp;收件人：</font></td>
<td width="75%" height="18"> 
<SELECT NAME="recipients">
<option value=0>所有注册用户</option>
<option value=1>所有班级管理员</option>
<option value=2>所有系统管理员</option>
</SELECT>
</td>
</tr>
<tr  Class=LightTableBody> 
<td width="25%" height="18">&nbsp;&nbsp;邮件主题：</font></td>
<td width="75%" height="18"> 
<input type="text" name="title" size="65" >
</td>
</tr>
<tr   Class=LightTableBody >
<td width="25%" height="18">&nbsp;&nbsp;邮件内容：</font></td>
<td width="75%" height="18"> 
        <textarea name="content" cols=65 rows=8></textarea>
</td></tr>
<tr Class=DarkTableBody> 
<td height="23" colspan="2" align=right > 
<input type="submit" name="Submit" value="发 送" class=button>&nbsp;&nbsp;
<input type="reset" name="reset" value="重 写" class=button>
</td>
</tr>
</table>
</form>
<%
End Sub


Sub sendmail()
	if Request("title")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请输入邮件标题。"
		founderr=True
	Else
		mailtopic=Request("title")
	End if
	if Request("content")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请输入邮件内容。"
		founderr=True
	Else
		mailbody=Request("content")
	End if

	if founderr=True Then 
		Response.Write "<br>"&Errmsg
		Exit Sub
	End if

	mailfrom=StrVar(2)
	if request("recipients")="2" then
		sql="select S.email from student S inner join admin A on A.adminid=S.studid where S.locked>1"
	elseif request("recipients")="1" then
		sql="select distinct S.email from student S inner join joinclass J on S.userid=J.userid where J.degree>6"
	else
		sql="Select email from student"
	end if
	
	Set rs=conn.execute(sql)
	if not (rs.eof and rs.bof) Then

		do while not rs.eof
		mailto=rs("email")
			select case cint(IntVar(5))
			case 0
				ErrMsg=ErrMsg+"<br>"+"<li>你已在同学录参数中设置不支持邮件功能！"
				Exit Sub
			case 1
				Call jmail_smtp()
			case 2
				Call Cdonts()
			case 3
				Call aspemail()
			case 4
				Call jmail_msg()
			End select
		rs.movenext
		loop
	End if

	if SendMailStatus="0K" Then
		msg="邮件发送成功"
	Else
		msg="<br>"+"<li>由于以下原因邮件发送失败！</li>"
		msg=msg+"<br><font color=gray>"&SendMailStatus&"</font>"
	End if

	Response.Write "<BR><BR><CENTER>"&msg&"</CENTER>"

End Sub
%>



