<!--#INCLUDE FILE="../HXINCLUDE/HXINCLUDEHEAD.ASP"--><!--#INCLUDE FILE="../HXINCLUDE/HX_photo.asp"-->
<%
ColumnName="":Tablename="HX_MailChit":Orderby="":const WSOAWith=450:const WSOAHeight=260:tuserid=request("tuserid"):tusername=request("tusername"):action=request("action"):subject=request("subject")
if action="send" then
set upload=new upload_file:WS_MailToUid=upload.form("WS_MailToUid"):subject=upload.form("subject"): Content=upload.form("Content"):pagename=upload.form("pagename")
end if
select case pagename
case "send"
  call WS_S.ChkIsOuter()
  filepath="Emailannex/"
  for each formName in upload.File
	set file=upload.File(formName)
	if file.filesize>10 then
    fileExt=lcase(file.FileExt)	'得到的文件扩展名不含有.
	if fileext<>"doc" and fileext<>"txt" and fileext<>"rar" then
		fileExt="gif"
		response.write "<script language=javascript>alert('只能上传DOC、TXT、RAR格式的文件！');history.go(-1);</script>"
		response.end
    end if
	if file.filesize>(200000*1024) then
		response.write "<script language=javascript>alert('文件大小不能超过200M！');history.go(-1);</script>"
		response.end
	end if
  randomize
  ranNum=int(90000*rnd)+10000
  filename=filepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt 
  if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
    FileSeverPath=Server.mappath(FileName)
    file.SaveToFile FileSeverPath
	if WS_S.HX_ScanFile(FileSeverPath) then
    WS_S.CheckFile FileSeverPath,True 
    HX_GoBack "对不起,您上传的文件中含有木马程序,所以不能上传!",""
    end if
   end if
   set file=nothing 
   end if 
   next 
	  if WS_MailToUid<>"" then	  
	    set mrs=WS_S.HX_SetRSD(ColumnName,Tablename,"")
		Emailarr=split(WS_MailToUid,"|")
		for ii=0 to ubound(Emailarr)
		  if WS_S.HX_IsNUM(Emailarr(ii)) then
           mrs.addnew
		   mrs("WS_MailToUid")=cint(Emailarr(ii))
		   mrs("WS_MailSendUid")=loginuid
		   mrs("WS_MailSendDate")=now
		   mrs("WS_MailBody")=Content
		   mrs("WS_MailObject")=subject
		   mrs("WS_MailAnnex")=FileName
		   mrs.update
		   end if	
		 next    
	  end if
	   msg=subject&"邮件发送成功！"
	   call WS_S.HX_RSClose(mrs)
	   call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
	   if upload.form("windowclose")="windowclose" then
	     response.Write "<script>alert('"&msg&"');window.close();</script>"
		 response.End()
	   else
         HX_GoBack msg,"sendmessage.asp"
	   end if
       set upload=nothing    
case "dosave"
	    set mrs=WS_S.HX_SetRSD(ColumnName,Tablename,"")
		   mrs.addnew:mrs("WS_MailSendUid")=loginuid:mrs("WS_MailSendDate")=now:mrs("WS_MailBody")=Content:mrs("WS_MailObject")=subject:mrs("WS_MailIsRead")=-1:mrs("WS_MailIsSend")=0:mrs.update	
		   msg=subject&"邮件保存成功!!"
		   insave=mrs("WS_MAID")
	      WS_S.HX_RSClose mrs 
	     call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
         HX_GoBack msg,"sendmessage.asp?MAID="&insave
case else
       Maid=request("MAID")
       if WS_S.HX_ISNUM(Maid) then
	    Orderby=" where WS_MAID="&Maid
	    set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
		if rs.recordcount>0 then
            subject=rs("WS_MailObject")
			body=rs("WS_MailBody")
			if request("MailIsSend")="MailIsSend" then
			  rs("WS_MailIsSend")=1
			  rs.update
			end if			
	     end if
		 WS_S.HX_RSClose rs
	   end if   
end select
response.write "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>发邮件</title><link rel=stylesheet type=text/css href='../HXinclude/HX_Style.css'><script src='../HXinclude/HX_Function.js'></script></head><body topmargin='10' leftmargin='0' bottommargin='10'><table width='596'  border='0' cellspacing='1' cellpadding='0' align=center bgcolor='#613c25'><tr><td colspan='2' bgcolor=FFFBE8><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr><td height='25' background='../hximages/titleline.gif'><font class='fontmenu'>发邮件</font></td></tr></table><table border='0' cellspacing='1' cellpadding='3' width='100%' align='center' bgcolor='#FFFBE8'><form action='sendmessage.asp?action=send' method='post' enctype='multipart/form-data' name='form1' target='_self'>"
if WS_S.HX_ISNUM(tuserid) and tusername<>"" then  response.write "<tr><td colspan='2'>&nbsp;发送到（"&tusername&"）的邮件</td></tr><input type='hidden' name='WS_MailToUid' value='"&tuserid&"'><input type='hidden' name='WS_MailToName' value='"&tusername&"'><input type='hidden' name='windowclose' value='windowclose'>" else  response.write "<tr bgcolor='#FFFBE8'><td width='102'> &nbsp;&nbsp;收信人：</td><td width='477'><input type='hidden' name='WS_MailToUid'><input type='text' name='WS_MailToName' size='46' readonly> <input onclick=""openwin(510,500,'../HXinclude/HX_Selectuser.asp?checkuser=MailTo')"" name='checkuser' type='button' value='选择' class='bdlogin' title='选择收信人'></td></tr>"
response.write "<tr bgcolor='#FFFBE8'><td width='102'> &nbsp;&nbsp;主&nbsp;&nbsp;题：</td><td><input name='subject' type='text' value='"&subject&"' size='59'></td></tr><tr bgcolor='#FFFBE8'><td> &nbsp;&nbsp;附&nbsp;&nbsp;件：</td><td><input type='file' name='WS_Annex' maxlength='300' size='46'></td></tr><tr bgcolor='#FFFBE8'><td width='102' valign='top'>&nbsp;&nbsp;正&nbsp;&nbsp;文：</td><td>"
session("WSOACOMCONTENT")=body%><!--#include file=../HXEditor/WSOAEDITOR.ASP--><%response.write "</td></tr><tr bgcolor='#FFFBE8'><td width='102'>&nbsp;</td><input type='hidden' name='pagename' value='send'><input name='Content' type='hidden' value=''><td><input type='button' name='dosend' value=' 发 送 ' onClick='aa()'>"
if WS_S.HX_ISNUM(tuserid) and tusername<>"" then response.write " <input type='button' name='dodsend' value=' 关 闭 ' onClick='window.close();'>" else response.write " <input type='button' name='dodsend' value=' 保 存 ' onClick='bb()'>"
response.write "</td></tr></form></table></td></tr></table>"%>