📄 复件 update.asp
字号:
<%
'OA 表单生成器1.0
'功能:内部信箱内容提交后处理
'参数:request.form("addedit_subed")="send"#表单提交;
%>
<!--#include file="../inc/Secure.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Const.asp"-->
<%
formPath="./files/"
Set FileObj=Server.CreateObject("DBstep.FileUpLoad") '调用文件上传组件
'response.buffer=false
'------------------------------------------------设置参数
LoginID=trim(session("LoginID")) : if LoginID="" then LoginID=0 '当前用户ID
pid=FileObj.Request("id") '记录ID
pmod=FileObj.Request("mod") '模式(0撰写,1修改,2回复,3转发)
if pmod="" then pmod=0
pmod=cint(pmod)
AccessoryID=FileObj.Request("AccessoryID")
if AccessoryID<>"" then
AccessoryID=left(AccessoryID,len(AccessoryID)-1)
end if
'response.write AccessoryID
'------------------------------------------------
if pid<>"" then
'取邮件记录
'------------------------------------------------取记录
'取要查看的记录 (返回rs对象)
table="tbioamail" '表名
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from " & table & " where ID="&pid
rs.open sql,oConn,1,1
'------------------------------------------------
'------------------------------------------------标记为已读
if rs("read_mod")=false then
sql="update " & table & " set read_mod=1 where ID="&pid
oConn.Execute sql
end if
'------------------------------------------------
Select Case pmod
Case 1 '修改
show_nbsjr=rs("nbsjr")'收件人
show_subject=Server.HTMLEncode(rs("subject"))'主题
show_body=Server.HTMLEncode(rs("body"))'内容
Case 2 '回复
show_nbsjr=rs("fjr")
show_subject="Re:"&Server.HTMLEncode(rs("subject"))
show_body=""
Case 3 '转发
show_nbsjr=""
show_subject="Fw:"&Server.HTMLEncode(rs("subject"))
show_body=vbcrlf&vbcrlf&vbcrlf&vbcrlf&"= = = = = = 下面是转发邮件 = = = = = = ="&vbcrlf&Server.HTMLEncode(rs("body"))&vbcrlf&"= = = = = = = = = = = = = = = = = = = ="
Case Else
show_nbsjr=""
show_subject=""
show_body=""
End Select
end if
'------------------------------------------------编辑记录
table="tbioamail" '表名
if FileObj.Request("addedit_subed")="send" then
'发送表单提交后
'接受录入参数
input_nbsjr=FileObj.Request("input_nbsjr")'内部收件人
input_subject=FileObj.Request("input_subject")'主题
input_body=FileObj.Request("input_body")'内容
input_backup_mod=FileObj.Request("input_backup_mod")'是否保存到寄件夹
if input_backup_mod="" then input_backup_mod=0
input_revert_mod=FileObj.Request("input_revert_mod")'对方读到信时给我回应
'保存到寄件夹
if input_backup_mod=1 then
'添加时使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(LoginID,LoginID,input_nbsjr,input_subject,input_body,"寄件夹",input_revert_mod)
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
sql = "SELECT @@IDENTITY AS 'Identity'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判断是否有附件上传
formPath="./files/"
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判断目录是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上传文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存状态
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存状态
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
end if
'发送邮件
ary_nbsjr=Split(input_nbsjr,",")'内部收件人列表(数组)
for j=0 to ubound(ary_nbsjr)
'添加时使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(trim(ary_nbsjr(j)),LoginID,input_nbsjr,input_subject,input_body,"收件夹",input_revert_mod)
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
'OA精灵提醒
body="新邮件通知:"&vbcrlf&vbcrlf
body=body&"发件人:"&getusername(LoginID)&vbcrlf
body=body&"发件时间:"&now()&vbcrlf
body=body&"邮件主题:"&input_subject&vbcrlf
'Call AgentSysMsg(trim(ary_nbsjr(j)),body)'OA精灵提醒
sql = "SELECT max(id) from tbioaMail"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判断是否有附件上传
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判断目录是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
Set fso=nothing
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上传文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存状态
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存状态
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
next
'删除草稿
if pmod=1 then
if AccessoryID<>"" then
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判断目录是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
sql = "SELECT * from tbioaMail_Accessory WHERE id in (" & AccessoryID & ")"
set rs=Server.CreateObject("ADODB.RecordSet")
' response.write sql
rs.open sql,oconn,1,3
do while not rs.eof
set fs = fso.GetFile(server.mappath(formPath&rs("parentID")&"/"&rs("FileName")))
' response.write server.mappath(formPath&Pid&"/"&rs("FileName"))
fs.move (server.mappath(formPath&Parentid&"/"&rs("FileName")))
' response.write server.mappath(formPath&Parentid&"/"&rs("FileName"))
sql="UPDATE tbioaMail_Accessory SET Parentid=" & Parentid & " WHERE id="&rs("id")
' response.write sql
oConn.Execute sql
rs.movenext
loop
rs.close
set fso=nothing
end if
sql = "SELECT * from " & table & " WHERE ID="&pid&" and folder='草稿夹'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
if not rs.eof then
Parentid=rs("id")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=true then '判断目录是否存在
Fso.DeleteFolder(server.mappath(formPath&Parentid))
end if
set fso=nothing
end if
rs.close
set rs=nothing
oConn.Execute "DELETE FROM " & table & " WHERE ID="&pid&" and folder='草稿夹'"
end if
'发送成功提示信息
if pmod=0 then
word="<p>内部邮件已成功发送!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href=mail_edit.asp>撰写新邮件</a>"
else
word="<p>内部邮件已成功发送!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href='javascript:history.go(-2)'>返回</a>"
end if
end if
if FileObj.Request("addedit_subed")="save" then
'暂存表单提交后
'接受录入参数
input_nbsjr=FileObj.Request("input_nbsjr")'内部收件人
input_subject=FileObj.Request("input_subject")'主题
input_body=FileObj.Request("input_body")'内容
input_backup_mod=FileObj.Request("input_backup_mod")'是否保存到寄件夹
input_revert_mod=FileObj.Request("input_revert_mod")'对方读到信时给我回应
'保存到草稿夹
'修改时使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(LoginID,LoginID,input_nbsjr,input_subject,input_body,"草稿夹",input_revert_mod)
if pmod<>1 then
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
sql = "SELECT @@IDENTITY AS 'Identity'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
else
sql="UPDATE " & table & " SET "
for i=0 to ubound(field1)
sql = sql & field1(i) & "='" & replace(value1(i),"'","''") & "'"
if i <> ubound(field1) then sql=sql & "," else sql=sql & " where id=" & pid
next
oConn.Execute sql
parentID=Pid
end if
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判断是否有附件上传
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判断目录是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
set fso=nothing
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上传文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存状态
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存状态
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
'保存成功提示信息
if pmod=1 then
response.redirect "mail_edit.asp?id="&pid&"&mod=1"
response.end
elseif pmod=0 then
word="<p>邮件已成功保存!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href=mail_edit.asp>撰写新邮件</a>"
else
word="<p>邮件已成功保存!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href='javascript:history.go(-2)'>返回</a>"
end if
end if
set FileObj=nothing
'------------------------------------------------
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/main.css" type=text/css>
<title>main</title>
</head>
<body topmargin="10" leftmargin="10">
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td><img border="0" src="../images/icon_menu.gif" align="left"> 内部信箱->编辑邮件</td>
</tr>
</table>
<hr width="100%" size=1 color="#000000">
<br>
<div align="left">
<table width="580" cellspacing="1" cellpadding="2" class="tab">
<tr>
<td width="20%" class="tdTop">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="tdTop">
<p align="left"><img border="0" src="../images/icon_title.gif" align="left">
<%
Select Case pmod
Case 2
response.write("回复邮件")
Case 3
response.write("转发邮件")
Case Else
response.write("写邮件")
End Select
%>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="td1">
<table border="0" width="100%" cellspacing="10" cellpadding="0">
<tr>
<td width="36%">
<p align="right"><img border="0" src="../images/edit.gif" width="32" height="32">
</td>
<td width="64%"><p> </p>
<%=word%>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="25%" class="tdBottom">
</td>
</tr>
</table>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -