<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>回复邮件</title>
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/char.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	'强制浏览器重新访问服务器下载页面，而不是从缓存读取页面
	end if
	Response.Buffer = True
	Response.Expires = -1
	Response.ExpiresAbsolute = Now() - 1
	Response.Expires = 0
	Response.CacheControl = "no-cache"
	'以下为电子邮件发送代码
	action=Trim(Request.QueryString("action"))
	if action="sendmail" then
		Set rs = Server.CreateObject("ADODB.Recordset")
		sql="select * from sendmail"
		rs.open sql,conn,1,1
		if rs("open1")=0 then
			mailaddress=rs("mailaddress")
			mailusername=rs("mailusername")
			mailuserpass=rs("mailuserpass")
			mailsend=rs("mailsend")
		
		
			'发送邮件
			On Error Resume Next
			'发送推荐邮件
			topic=Trim(Request.Form("subject"))
			
			mailbody="<html>"
			mailbody=mailbody & "<title>报名咨询信件信息</title>"
			mailbody=mailbody & "<body>"
			mailbody=mailbody & "<TABLE border=0 width='95%' align=center><TBODY><TR>"
			mailbody=mailbody & "<TD valign=middle align=top>"
			mailbody=mailbody & Trim(Request.Form("message"))
			mailbody=mailbody & "</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
			mailbody=mailbody & "</body>"
			mailbody=mailbody & "</html>"
			rs.close
			
			Set JMail=Server.CreateObject("JMail.Message")
			JMail.Charset="gb2312"
			JMail.ContentType = "text/html"
			jmail.from = mailsend
			jmail.silent = true
			jmail.Logging = true
			jmail.FromName = topic
			jmail.mailserverusername = mailusername
			jmail.mailserverpassword = mailuserpass
			jmail.AddRecipient Trim(Request.Form("email"))
			jmail.body=mailbody
			JMail.Subject=topic
			if not jmail.Send ( mailaddress ) then
				SendMail=""
			else
				SendMail="OK"
			end if
			if SendMail="OK" then
				sendmsg="您的回复信息已经成功发往!"
			else
				sendmsg="系统出错，您的回复信息未能发送成功!"
			end if
				response.write"<SCRIPT language=JavaScript>alert('"&sendmsg&"');"
				response.write"javascript:window.close();</SCRIPT>"
		else
			rs.close
			response.write"<SCRIPT language=JavaScript>alert('系统暂时关闭邮件发送功能，回复信息未能发送到咨询者信箱');"
			response.write"javascript:window.close();</SCRIPT>"
		end if
	end if
'邮件发送代码完毕
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/public.css" rel="stylesheet" type="text/css" media="all" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkuserinfo()
{
   if(checkspace(document.userinfo.email.value)) {
	document.userinfo.email.focus();
    alert("对不起，请填写正确的email地址！");
	return false;
  }
   if(checkspace(document.userinfo.subject.value)) {
	document.userinfo.subject.focus();
    alert("对不起，请填写信件标题！");
	return false;
  }
   if(checkspace(document.userinfo.message.value)) {
	document.userinfo.message.focus();
    alert("对不起，请填写信件内容！");
	return false;
  }
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
</head>
<body bgcolor="#ffffff" text="#000000" oncontextmenu=self.event.returnValue=false bottommargin="0" topmargin="0" rightmargin="0" leftmargin="0">
<form name="userinfo" method="POST" action="?action=sendmail" onSubmit="return checkuserinfo()">
 <table width="477" border="0" align="center" cellspacing="1" cellpadding="0">
    <tr> 
      <td class="tab_03" height="30">　<img src="../images/pn_16.gif" width="19" height="13" align="absmiddle"><b>咨询报名邮件回复</b></td>
    </tr>
    <tr><td height="1"></td></tr>
  </table>
<%
	id=ReplaceBadChar(int(Trim(Request.QueryString("id"))))
	tid=ReplaceBadChar(int(Request.Cookies("admin_train_id")))
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql="select * from train_join where id="&id&" and tid="&tid&""
	rs.open sql,conn,1,1
	if rs.eof then
		response.write"<SCRIPT language=JavaScript>alert('对不起，非法操作！');"
		response.write"javascript:window.close();</SCRIPT>"
		response.end
	else
%>
  <table width="477" border="0" align="center" cellspacing="1" cellpadding="5" bgcolor="E6E6E6">
    <tr bgcolor="#FFFFFF"> 
      <td width="80" height="21" bgcolor="#EfEfEf"><b>收件人</b></td>
      <td><input type="text" name="email" size="25" value="<%= rs("email") %>" alt="email" readonly/> </td>
    </tr>
    
    <tr bgcolor="#FFFFFF"> 
      <td height="25" bgcolor="#efefef"><b>信件标题</b></td>
      <td><input type="text" name="subject" size="50" value="关于您咨询《<%= Trim(Request.QueryString("text")) %>》的回复"></td>
    </tr>
    
    <tr bgcolor="#FFFFFF"> 
      <td valign="top" height="25" bgcolor="#efefef" ><b>内容</b></td>
      <td>
      	<textarea name="message" cols="54" rows="12">咨询邮件的内容：<%=rs("notice")%>




下面是此咨询的回复：</textarea> 
      </td>
    </tr>
    
    <tr bgcolor="#FFFFFF"> 
      <td valign="top" height="25">&nbsp;</td>
      <td>
      <input type="submit" class="button" name="SubmitSend" value=" 发送 " >
      <input type="button" class="button" name="" value=" 取消 "  onclick="window.close()"> 
      </td>
    </tr>
    
  </table>
<%
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
</form>
</body>
</html>