<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="admin_Checkuser.asp"-->
<!--#include file="inc/HTMLEncode.asp"-->
<!--#include file="../inc/email.asp"-->
<%Server.ScriptTimeOut=999999999%>
<HTML><HEAD><title><%=StrVar(1)%>--管理页面</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<!--#include file="inc/admin_main.css"-->
</HEAD>
<BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=admin_index.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 Class=TableBorder><tr><td class=forumRowHighlight><B><a name=top>说明</a></B>：当校友录中有大量的注册用户时，如果邮件收件人选择"所有注册用户"，将消耗大量的服务器资源。<br>
</td></tr></table>
<form method="POST" action=admin_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> 
<td width="25%" height="18" class=forumrow>&nbsp;&nbsp;收件人：</font></td>
<td width="75%" height="18" class=forumrow> 
<SELECT NAME="recipients">
<option value=0>所有注册用户</option>
<option value=1>所有学校管理员</option>
<option value=2>所有系统管理员</option>
</SELECT>
</td>
</tr>
<tr> 
<td width="25%" height="18" class=forumrow>&nbsp;&nbsp;邮件主题：</font></td>
<td width="75%" height="18" class=forumrow> 
<input type="text" name="title" size="65" >
</td>
</tr>
<tr>
<td width="25%" height="18" class=forumrow>&nbsp;&nbsp;邮件内容：</font></td>
<td width="75%" height="18" class=forumrow> 
        <textarea name="content" cols=65 rows=8></textarea>
</td></tr>
<tr> 
<td height="23" colspan="2" align=right Class=forumrowhighlight> 
<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 
	Call Error("Information",ErrMsg)
		Exit Sub
	End if
	mailfrom=StrVar(2)
	MailFromName=StrVar(1)
	if request("recipients")="2" then
		sql="select S.email from student S inner join admin A on A.managerid=S.studid"
	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>你已在校友录参数中设置不支持邮件功能！"
				Call Error("Information",ErrMsg)
				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
 Call adminmsg(""&msg&"")

End Sub
%>