weiqihp 2003年08月15日
不能重定向?!在线等!!
<%@ Language=VBScript %>
<% Response.Expires = 0 %>
<% Response.Buffer = true %>
<!-- #INCLUDE FILE = "../share/Connectdb.asp" -->
<!-- #INCLUDE FILE = "../share/pubfun_mail.asp" -->
<!-- #INCLUDE FILE = "../share/pubfunction.asp" -->

<%
dim strType,objFs
Set objFs = Server.CreateObject("Scripting.FileSystemObject")
'strType = request("type") '操作类型:delall表示删除,否则表示接收
dim strTimeOut,strCount '接收超时参数和一次接收邮件数参数
strTimeOut = 300
strCount = Request("yjcount")
if strTime = "" or not IsNumeric(strTime) then strTime = 90
if strCount = "" or not IsNumeric(strCount) then strCount = ""
Server.ScriptTimeout = strTimeOut '设定邮件接收最长时间

on error resume next
dim strygbh,strSql,mailRs,strPOP3bh,currPOP3bh,i,objPOP3,sCount,currPOP3,strMessage,ii,Msg
strygbh = Session("uYGBH")
strPOP3bh = request("delyjjmc")
Set mailRs = Server.CreateObject("ADODB.RecordSet")
Set objPOP3 = Server.CreateObject( "LKOAMAILCom.clsAspMailCom" )
strMessage = ""
'取出POP3 SERVER编号,进行多个POP3邮件收取

strSql = "select * from oa_mail_pop3 where rybh=" & strygbh
mailRs.Open strSql,conn,1,1
do while not mailRs.EOF
sCount = 0
currPOP3 = split(mailrs("POP3"),":")

Response.Write "<br>接收<b>" & server.HTMLEncode(mailrs("pop3mc")&"") & "</b>的邮件...<br>"
Response.Flush
with objPOP3.poSendMail
.UseSMTPAuthentication = false
.UsePopAuthentication = true
.POP3Host = currPOP3(0)
.POP3Port = currPOP3(1)
.Username = mailRs("pop3yhm")
.Password = Decrypt(mailRs("pop3dlmm"),false)
'.IsOnlyTotalMail = false
'if UCase(strType) = "DELALL" then .IsOnlyDelMail = true
.IsDelMail = cbool(mailrs("scbz")&"")
'response.end
.Send


If clng(.Mails.Count) > 0 and not.IsOnlyDelMail then
For ii = 1 to .Mails.Count
'response.Write "MSG::::" & .Mails(ii) & "<p>"
Lkoa_SaveEmail .Mails(ii),mailRs("jsyjj"),ii '调用存储外部邮件函数
Next

strMessage = "在 <B>" & mailRs("pop3mc") & "</B> 上收取了<font clor=blue> " _
& .Mails.Count & "</font> 封邮件!邮件存储在您的<b>" _
& "<a href=mail_list.asp?yjjmc=" & mailRs("jsyjj") & ">" _
& server.HTMLEncode(mailRs("jsyjj")) & "</a></b><br>"
Response.Write strMessage

DO WHILE .Mails.Count>0
Mails.Remove(1)
LOOP
End If

End With
mailRs.MoveNext
Loop



objPOP3.Disconnect
Set objPOP3 = Nothing
mailRs.Close
conn.Close
Set conn = Nothing
Set objFs = Nothing
Response.Redirect "mail_list.asp?yjjmc=收件夹" '就是这儿,居然不能重定向!
%>

<%

'存储外部邮件函数
Function Lkoa_SaveEmail(emailObject,emailYjjmc,iiii)
dim funSql,funRs,myFile,strTime,strmbPath,strAtth,iAtth,strYjxh,fileAtth
dim funjjrxm,funjjrdz,funsjrdz,funcs,funrq,funzhuti,funzwljwj,funyjjmc,funtsbz,funydbz,funyjbz,funyxjb,funyjdx,funfjlj
dim objMime
Set funRs = Server.CreateObject("ADODB.RecordSet")
set objMime = Server.CreateObject("LKOAMIMEMail.CMIMEMail")
objMime.Receive emailObject
funjjrxm = replace(replace(objMime.From,"'","''"),chr(0),"")
funjjrdz = replace(replace(objMime.ReplyTo,"'","''"),chr(0),"")
funsjrdz = replace(replace(objMime.MessageTo,"'","''"),chr(0),"")
funcs = replace(replace(objMime.BCC,"'","''"),chr(0),"")
funrq = objMime.SendDate
IF not isdate(funrq) then
funrq = replace(funrq,"+","")
if not isdate(funrq) then
funrq = ""
else
funrq = formatdate(funrq,"YYYYMMDDHHMMSS","-")
end if
ELSE
funrq = formatdate(funrq,"YYYYMMDDHHMMSS","-")
end if
'Response.Write "tIME ZONE:" & funrq
funzhuti = replace(replace(objMime.Subject,"'","''"),chr(0),"")

'定义存储邮件的物理路径
strTime="LKMAIL_W" & getMaxMailID
strmbPath = getMailFolder(PubMail_webSjj,Session("uYGBH"),true)
Set myFile = objFs.CreateTextFile(strmbPath & strTime & ".eml",true)
myFile.Write emailObject '写入邮件原始内容到文件
myFile.Close
Set myFile = Nothing
'EncryptFile strmbPath & strTime & ".lkml" '文件加密
'Response.Write strmbPath & strTime & ".lkml"
funzwljwj = strTime & ".eml"

funyjjmc = replace(emailYjjmc,"'","''")
funtsbz = ""
funydbz = ""
funyjbz = "0"
funyxjb = "3"
if len(objMime.Priority & "")=1 then
funyxjb = objMime.Priority
end if

'取邮件大小
Set myFile = objFs.GetFile(strmbPath & strTime & ".eml")
funyjdx = myFile.size
Set myFile = Nothing
'funzhuti = left(funzhuti,len(funzhuti)-1)
'Response.Write "主题:" & asc(right(funzhuti,1)) & "<p>"
'将邮件对应信息存储到数据库
funSql = "insert into oa_mail_yj (ygbh,jjrxm,jjrdz,sjrdz,cs,rq,zhuti,zwljwj,yjjmc,tsbz,ydbz,yjbz,yxjb,yjdx) " _
& " values (" & Session("uYGBH") & ",'" & funjjrxm & "','" & funjjrdz & "','" & funsjrdz& "','" & funcs & "','" & funrq & "','" & cstr(funzhuti) & "','" &funzwljwj & "','" _
& funyjjmc & "','" & funtsbz & "','" & funydbz & "','" & funyjbz & "','" & funyxjb & "', " & funyjdx & ")"
'Response.Write server.HTMLEncode(funSql) & "<br>"
conn.Execute funSql

'1、取该邮件的序号,用于附件数据存储时关联
stryjxh = 0
funSql = "select max(yjxh) from oa_mail_yj where ygbh=" & Session("uYGBH") & " and zwljwj='" & funzwljwj & "'"
funRs.Open funSql,conn,adOpenStatic
if not funRs.EOF then
if funrs(0) & "" <> "" then
strYjxh = clng(funRs(0))
end if
end if
funRs.Close
Set funRs = Nothing

'存储邮件对应附件
if objMime.AttachmentCount > 0 then


'2、取出该邮件的附件信息,相应存储到文件和数据库中去
''Set strAtth = objMime.a

For iAtth = 1 To objMime.AttachmentCount
''Set fileAtth = strAtth(iAtth)

strTime = "MAIL" & strYjxh & "_FJ" & iAtth & stryxbh


'调用自己的函数来取附件并存储附件
objMime.RetriveAttachments getMailFolder(PubMail_Temp,Session("uYGBH"),true), iAtth

'fileAtth.SaveToFile getMailFolder(PubMail_Temp,Session("uYGBH"),true) & fileAtth.Name '存储附件到临时目录
funfjlj = strTime & "." & objFs.GetExtensionName(getMailFolder(PubMail_Temp,Session("uYGBH"),false) & objMime.AttachName)

'copy临时目录的附件文件,改名存储在附件目录
objFs.CopyFile getMailFolder(PubMail_Temp,Session("uYGBH"),false) & objMime.AttachName, _
getMailFolder(PubMail_Fj,Session("uYGBH"),true) & funfjlj

objFs.DeleteFile getMailFolder(PubMail_Temp,Session("uYGBH"),false) & objMime.AttachName,True '删除临时目录中的附件文件
'Response.Write fileAtth.Name & ":" & getMailFolder(PubMail_FJ,Session("uYGBH"),true) & strTime & "." & fileAtth.Name & "<br>"

'向数据库写入相应信息
funSql = "insert into oa_mail_fj (yjxh,fjmc,fjlj,fjbz) values ('" & strYjxh _
& "','" & objMime.AttachName & "','" & funfjlj & "','1')"
conn.Execute funSql

Next
end if
Set objMime = Nothing
'Response.Write emailObject.Text & "<p><p>" & emailObject.Body & "<p><p>" & emailObject.BodyText
End Function

%>
...全文
46 点赞 收藏 6
写回复
6 条回复

还没有回复,快来抢沙发~

发动态
发帖子
ASP
创建于2007-09-28

1.9w+

社区成员

35.7w+

社区内容

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区公告
暂无公告