<!--#include virtual="/incs/config.asp"-->

<%
on error resume next
chk_log()
chk_newpwr 4,0,0

module=SafeRequest("module")
select case module
   case "snd_rnw"
substrContent = "entryclass:sys_mng"&VEnd
   substrContent =substrContent &"entrytype:snd_rnw"&VEnd
   substrContent =substrContent &"entryuser:"&entryuser&VEnd
   substrContent =substrContent &"entrypass:"&entrypass&VEnd
   substrContent =substrContent& "agentname:"&agentname&Vend
   substrContent =substrContent& "agentpass:"&agentpass&Vend
   substrContent = substrContent  &"m_tag:" & trim(SafeRequest("m_tag")) & VEnd
   substrContent = substrContent  &"m_day1:" & trim(SafeRequest("m_day1")) & VEnd
   substrContent = substrContent  &"m_day2:" & trim(SafeRequest("m_day2")) & VEnd
   substrContent = substrContent  &"m_day3:" & trim(SafeRequest("m_day3")) & VEnd
   substrContent = substrContent  &"." & VEnd
   turnurl="/master/sysmng/snd_mng/snd_rnw.asp"
   case "snd_add"
substrContent = "entryclass:sys_mng"&VEnd
   substrContent =substrContent &"entrytype:snd_add"&VEnd
   substrContent =substrContent &"entryuser:"&entryuser&VEnd
   substrContent =substrContent &"entrypass:"&entrypass&VEnd
   substrContent =substrContent& "agentname:"&agentname&Vend
   substrContent =substrContent& "agentpass:"&agentpass&Vend
   substrContent = substrContent  &"ms_mod:" & trim(SafeRequest("ms_mod")) & VEnd
   substrContent = substrContent  &"ms_tpe:" & trim(SafeRequest("ms_tpe")) & VEnd
   substrContent = substrContent  &"ms_ifhtm:" & trim(SafeRequest("ms_ifhtm")) & VEnd
   substrContent = substrContent  &"ms_nme:" & trim(SafeRequest("ms_nme")) & VEnd
   substrContent = substrContent  &"ms_ttl:" & trim(Request("ms_ttl")) & VEnd
   substrContent = substrContent  &"ms_bdy:" & trim(Request("ms_bdy")) & VEnd
   substrContent = substrContent  &"ms_ifagt:" & trim(SafeRequest("ms_ifagt")) & VEnd
   substrContent = substrContent  &"." & VEnd
   turnurl="/master/sysmng/snd_mng/snd_lst.asp"
   case "snd_edt"
  ms_mod=SafeRequest("ms_mod") 
  newtag=SafeRequest("newtag") 
   if  instr(newtag,"标志")<=0 and newtag<>"" then
   substrContent = "entryclass:sys_mng"&VEnd
   substrContent =substrContent &"entrytype:snd_add"&VEnd
   turnurl="/master/sysmng/snd_mng/snd_lst.asp"
   ms_mod=newtag
else
   substrContent = "entryclass:sys_mng"&VEnd
   substrContent =substrContent &"entrytype:snd_edt"&VEnd
   turnurl="/master/sysmng/snd_mng/snd_edt.asp?msid="&SafeRequest("msid")
 end if

   substrContent =substrContent &"entryuser:"&entryuser&VEnd
   substrContent =substrContent &"entrypass:"&entrypass&VEnd
   substrContent =substrContent& "agentname:"&agentname&Vend
   substrContent =substrContent& "agentpass:"&agentpass&Vend
   substrContent = substrContent  &"msid:" & trim(SafeRequest("msid")) & VEnd
    substrContent = substrContent  &"ms_tpe:" & trim(SafeRequest("ms_tpe")) & VEnd
    substrContent = substrContent  &"ms_ifhtm:" & trim(SafeRequest("ms_ifhtm")) & VEnd
 substrContent = substrContent  &"ms_mod:" &ms_mod & VEnd
   substrContent = substrContent  &"ms_nme:" & trim(SafeRequest("ms_nme")) & VEnd
   substrContent = substrContent  &"ms_ttl:" & trim(Request("ms_ttl")) & VEnd
   substrContent = substrContent  &"ms_bdy:" & trim(Request("ms_bdy")) & VEnd
   substrContent = substrContent  &"ms_ifagt:" & trim(SafeRequest("ms_ifagt")) & VEnd
   substrContent = substrContent  &"." & VEnd
    case "snd_del"
substrContent = "entryclass:sys_mng"&VEnd
   substrContent =substrContent &"entrytype:snd_del"&VEnd
   substrContent =substrContent &"entryuser:"&entryuser&VEnd
   substrContent =substrContent &"entrypass:"&entrypass&VEnd
   substrContent =substrContent& "agentname:"&agentname&Vend
   substrContent =substrContent& "agentpass:"&agentpass&Vend
   substrContent = substrContent  &"msid:" & trim(SafeRequest("msid")) & VEnd
   substrContent = substrContent  &"." & VEnd
   turnurl="/master/sysmng/snd_mng/snd_lst.asp"
   case "snd_snd"
   conn.open constr
 ms_rec=SafeRequest("ms_rec")
 ms_ttl=Request("ms_ttl")
 ms_bdy=Request("ms_bdy")
 ms_ifhtm=SafeRequest("ms_ifhtm")
 gid=SafeRequest("gid")
 grd=SafeRequest("grd")
 ms_mod=SafeRequest("ms_mod")
 gnme=SafeRequest("gnme")
 if ms_rec="" then
      call errorpage(-2,"对不起，邮件收件人不能为空！")
end if	  
 if ms_ttl="" then
      call errorpage(-2,"对不起，邮件标题不能为空！")
end if	  
 if ms_bdy="" then
      call errorpage(-2,"对不起，邮件内容不能为空！")
end if	  
if ms_ifhtm<>"1" then
ms_ifhtm="0"
end if
recs=jmailsend(ms_rec,ms_ttl,ms_bdy,ms_ifhtm) 
   turnurl="/master/sysmng/snd_mng/snd_lst.asp?gid="&gid&"&grd="&grd&"&gnme="&gnme&"&ms_mod="&ms_mod
if recs then
      call okpage( turnurl)
else
      call errorpage(-2,"对不起，邮件发送失败！")
 response.end
end if

   case "snd_grp"
 Server.ScriptTimeOut=300 
   on error resume next
   conn.open constr
chk_newpwr 4,19,4
 ms_rec=SafeRequest("ms_rec")
 ms_rec_cls=SafeRequest("ms_rec_cls")
 ms_ttl=Request("ms_ttl")
 ms_bdy=Request("ms_bdy")
 ms_ifhtm=SafeRequest("ms_ifhtm")
 gid=SafeRequest("gid")
 grd=SafeRequest("grd")
 ms_mod=SafeRequest("ms_mod")
 gnme=SafeRequest("gnme")
 if ms_ttl="" then
      call errorpage(-2,"对不起，邮件标题不能为空！")
end if	  
 if ms_bdy="" then
      call errorpage(-2,"对不起，邮件内容不能为空！")
end if	  
if ms_ifhtm<>"1" then
ms_ifhtm="0"
end if
errorcount=0
successcount=0
''####################收件人不为空时
if  len(trim(ms_rec))>0 then
ms_recs=split(ms_rec,",")
for tempcnt=0 to ubound(ms_recs)
recs=jmailsend(ms_recs(tempcnt),ms_ttl,ms_bdy,ms_ifhtm) 
if recs then
successcount=successcount+1
else
errorcount=errorcount+1
end if
next
end if
''####################收件人不为空时
''####################等级不为空时
if chk_int(ms_rec_cls) then
select case ms_rec_cls
case "-1"
query="select u_eml from v_memlst order by u_nme"
case "-2"
query="select u_eml from v_memlst where  (c_pwr=1 or c_pwr=2) order by u_nme"
case "-3"
query="select u_eml from v_memlst where  (c_pwr=1) order by u_nme"
case "-4"
query="select u_eml from v_memlst where  (c_pwr=2) order by u_nme"
case "-5"
query="select u_eml from v_memlst where  (u_sys=3) order by u_nme"
case else
query="select u_eml from v_memlst where  (u_prc="&ms_rec_cls&") order by u_nme"
end select
rs.open query,conn,1,1
while not rs.eof
recs=jmailsend(trim(rs("u_eml")),ms_ttl,ms_bdy,ms_ifhtm) 
if recs then
successcount=successcount+1
else
errorcount=errorcount+1
end if
rs.movenext
wend
rs.close
end if
''####################等级不为空时
   turnurl="/master/sysmng/snd_mng/snd_grp.asp"
    Server.ScriptTimeOut=90
if err.number=0 then
      call infpage("10001 共计"&successcount&"个邮件发送成功，"&errorcount&"个邮件发送失败！",turnurl)
	  response.end
else
      call errorpage(-2,"对不起，邮件群发失败！")
 response.end
end if

end select
   doresult = hzsocket(substrContent)
    left5=left(doresult,5)
   If left5= "10000" Then
      call okpage( turnurl)
   Else
      call errorpage(-2,doresult)
   end if

 ''''''''''''''''''''''''''''''''''''''''''''''''''''

%>

