   <% 
	data_path="../../" 'ACC连接数据库路径，对SQL无效
	numid="19"
	dir="../err.asp" 
  %>
<!--#include file="../../conn/conn.asp"-->
<%
Response.ContentType = "text/xml"
Response.Expires = 0
mailuserpass=HOPE_MailPwd'邮箱密码
fromname=SystemEmail'邮箱地址
mailaddress=SMTPServer'邮箱服务器
strTitle=EmailTitle'标题
ms_ifhtm=Emaillei'类型
tomail=Emailinfo
if ms_ifhtm=1 then 
mailgs="text/html"'邮箱格式
else
mailgs=""
end if
Set rs2= Server.CreateObject("ADODB.Recordset") 
sql2="select top 1 * from websen_worldec_Temp"
rs2.open sql2,conn,1,1
strContent=rs2("mailbody")'内容
rs2.close
user=Request.QueryString("user")'会员ID 
Response.Write("<?xml version='1.0' encoding='gb2312'?>")
Response.Write("<user>")
if instr(user,",")>0 then
Set rsDvbbs=Server.createobject("adodb.recordset")
SqlDvbbs="Select Email,id FROM Websen_corporation Where id in ("&user&")" 
rsDvbbs.open SqlDvbbs,conn,1,3
if rsDvbbs.eof then
else
response.Write("<msg>")
do while not rsDvbbs.eof
Call SendMail ( rsDvbbs("Email"),strTitle,strContent,mailusername,mailuserpass,mailaddress,fromname)
 response.Write(rsDvbbs("id")&"|")
rsDvbbs.movenext
loop
if tomail<>"" then 
strToemailArray=split(tomail,",") 
for i=0 to UBound(strToemailArray)
	strToemailAddress=strToemailArray(i)
 	Call SendMail (strToemailAddress,strTitle,strContent,mailusername,mailuserpass,mailaddress,fromname)
Next	
end if
response.Write("</msg>")
end if
else
SqlDvbbs="Select Email,id FROM Websen_corporation Where id ="&user 
Set rsDvbbs=Server.createobject("adodb.recordset")
rsDvbbs.open SqlDvbbs,conn,1,3
if user<>"" then
 Response.Write("<msg>")
    Call SendMail (rsDvbbs("Email"),strTitle,strContent,mailusername,mailuserpass,mailaddress,fromname)
 if tomail<>"" then 
strToemailArray=split(tomail,",") 
for i=0 to UBound(strToemailArray)
	strToemailAddress=strToemailArray(i)
 	Call SendMail (strToemailAddress,strTitle,strContent,mailusername,mailuserpass,mailaddress,fromname)
Next	
end if
response.Write (rsDvbbs("id")&"|")
  Response.Write("</msg>")
  else
  Response.Write("<msg>错误!</msg>")
  end if
end if
Response.Write("</user>")
Sub SendMail (mail_email,mail_subject,mail_body,mailusername,mailuserpass,mailaddress,fromname)
	On Error Resume Next
	Dim JMail
	userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")             
	If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")    '获得真实IP这样的话在本地，在服务器测试都没有问题了	
	Set JMail = Server.CreateObject("JMail.Message")
	JMail.silent = true
	JMail.Charset = "gb2312"
	jmail.contentType = ""&mailgs&"" '邮件格式（HTML）
	JMail.ISOEncodeHeaders = False
	JMail.MailServerUserName = fromname '发信人的电子邮件地址
	JMail.MailServerPassword = mailuserpass '发信人的电子邮件密码
	JMail.From = fromname 
	JMail.FromName = fromname               '发信人的名字
	JMail.Subject = mail_subject
	JMail.Priority = 1
	JMail.AddHeader "Originating-IP",userip
	JMail.AddRecipient(mail_email)
	JMail.Body = mail_body
	JMail.Send(mailaddress)                        'SMTP地址         
	JMail.Close() 
	Set JMail = Nothing
End Sub
rsDvbbs.CLOSE
set rsDvbbs=Nothing
%>
