<!--#include file="Config.asp" -->
<div class='menu'>&nbsp;发送邮件</div>
<%

UserID=Trim(Request("BoxID"))
if instr(UserID,",")>0 then
UserArr=split(UserID,",")
Mail=eRead("User",int(UserArr(0)),"Mail")
for i=1 to ubound(UserArr)
Mail=Mail&","&eRead("User",int(UserArr(i)),"Mail")
next
else
Mail=eRead("User",int(UserID),"Mail")
end if

'------------------------------
'请看说明文字修改配置
'------------------------------
SendFrom = "dengnianwang@126.com" '管理员发送邮箱，发送人的邮箱
smtpserver = "smtp.126.com"  '发送人[SendFrom] 的 SMTP 服务器
sendusername = "dengnianwang"  '发送人[SendFrom] 的邮箱名称
sendpassword = "******"  '发送人[SendFrom] 的邮箱密码
SendTO = Trim(Request.Form("Mail"))  '接收邮箱，这个不用写，系统中自动调用
subject = Trim(Request.Form("Title"))  '发送标题，这个不用写，系统中自动调用
message = Trim(Request.Form("ItemNote")) '发送内容，这个不用写，系统中自动调用
SendName = "EIMS" '发送人[SendFrom] 的称呼

if action="send" then
if Trim(Request.Form("Mail"))="" or instr(Trim(Request.Form("Mail")),"@")<1 then WtMsg("无邮箱或邮箱错误")
if Trim(Request.Form("Title"))="" or Trim(Request.Form("ItemNote"))="" then WtMsg("标题或内容没有")
	if instr(SendTO,",")>0 then
	Send2=split(SendTO,",")
	for j=0 to ubound(Send2)
	Call SendJmail(sendFrom,trim(send2(j)),smtpserver,sendusername,sendpassword,subject,message,SendName)
	next
	else
	Call SendJmail(sendFrom,sendTO,smtpserver,sendusername,sendpassword,subject,message,SendName)
	end if
Response.Write "<script>alert('邮件发送成功！');location.href='UserList.asp?eType=0'</script>"
end if

Sub SendJmail(sendFrom,sendTO,smtpserver,sendusername,sendpassword,subject,message,SendName)
Dim MailMsg
On Error Resume Next
Set JMail=Server.CreateObject("JMail.Message")
JMail.Charset="utf-8"
JMail.ContentType = "text/html"
jmail.from = SendFrom
jmail.silent = true
jmail.Logging = true
jmail.FromName = SendName
jmail.mailserverusername = sendusername
jmail.mailserverpassword = sendpassword
jmail.AddRecipient sendTO
jmail.body=message
JMail.Subject=subject

if not jmail.Send (smtpserver) then
Response.Write "<script>alert('由于系统错误，邮件发送未成功！');history.back()</script>"
end if

End Sub

%>
<div class="content" align="center">
<Form name='eForm' method='post' action='?action=send'>
<table width="100%" border="0" cellspacing="1" cellpAdding="1" align="center">
      <tr>
        <td align="center" width="12%">接收邮件</td>
        <td align="left"><textarea name="Mail" style="width:680px;height:50px;"><%=Mail%></textarea></td>
      </tr>
      <tr>
        <td align="center" width="12%">邮件标题</td>
        <td align="left"><input name="Title" type="text" size="60"></td>
      </tr>
      <tr>
        <td align="center">邮件内容</td>
        <td align="left"><textarea name="ItemNote" style="width:680px;height:300px;visibility:hidden;"><%=ItemNote%></textarea></td>
      </tr>
      <tr bgcolor="#FFFFFF" valign="middle">
        <td></td>
        <td align="left"><input type="submit" name="Submit" value="发 送">
          &nbsp;&nbsp;
          <input type="button" value="返 回" onClick="history.go(-1);"></td>
      </tr>    
  </table>
</Form>
</div>
</body>
</html>