ASP写的JMail组件的邮件收取
当前位置:知识管理交流
→『 技术文档交流 』
"&Subject rs.addnew() rs("AccountCode")=Request("code") rs("SendMail")=MSGFrom rs("SendMailName")=MSGFromName rs("AcceptMail")=ReTo rs("CopyMail")=ReCC rs("ClassCode")=1 rs("MailTitle")=Subject if MSGHTMLBody="" then rs("MailBody")=replace(MSGBody,chr(10)," ") else rs("MailBody")=MSGHTMLBody end if rs("FileUrl")=FileUrl rs("FileName")=FileName rs("SendAcceptTime")=AcceptTime rs("MailState")=1 rs.update() next end if rs.close Set Attachments=Nothing Set TheMsg=Nothing if ifdelete then POP3.DeleteMessages end if POP3.Disconnect Set POP3=Nothing endconn() Response.write "" '转到收件箱 '---------将附件存储到本地服务器------------------ Sub getAttachments(J) Dim Path,AT,separator,i,iPath,Att,POP,Re Set POP = Server.CreateObject("JMail.POP3") POP.Connect EmailUserName,EmailUserPass,EmailUserPOP MSGBody=POP.Messages.Item(J).Body '纯文本内容 MSGHTMLBody=POP.Messages.Item(J).HTMLBody '超文本内容 MSGBody=Trim(MSGBody) MSGHTMLBody=Trim(MSGHTMLBody) AcceptTime=POP.Messages.Item(J).Date '接收时间 FileName="" FileUrl="" ReTo="" ReCC="" Set Att = POP.Messages.Item(J).Attachments separator = "," if Att.Count>0 then For i = 0 To Att.Count-1 If i = Att.Count-1 Then separator = "" End If Set AT = Att.item(i) if AT.Name<>".msg" then Path="/EMail/attachments/" & iRandom & "/" Call CreateAFolder(Server.Mappath(Path)) iPath=Server.Mappath(Path) & "\" & AT.Name AT.SaveToFile(iPath) FileUrl = FileUrl & Path & AT.Name & separator FileName = FileName & AT.Name & separator else if MSGHTMLBody="" then MSGHTMLBody=AT.data end if end if Next end if '--------------收件人------------ Set Recipients = POP.Messages.Item(J).Recipients separator = "," For i = 0 To Recipients.Count - 1 If i = Recipients.Count - 1 Then separator = "" End If Set Re = Recipients.item(i) If Re.ReType = 0 Then if ReTo<>"" then ReTo=ReTo & "," end if ReTo = ReTo & Re.EMail else if ReCC<>"" then ReCC=ReCC & "," end if ReCC = ReCC & Re.EMail End If Next Set Re=Nothing Set Recipients=Nothing '--------------------------------- Set AT=Nothing Set Att=Nothing POP.Disconnect Set POP=Nothing End Sub '--------随机函数------------------ Function iRandom() Randomize iRandom=Session("UserID")&month(date())&day(date())&Minute(time())&Second(time)&CLng(10000 * Rnd) end Function '--------创建新文件夹-------------- Sub CreateAFolder(Path) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.CreateFolder(Path) Set fso=Nothing End Sub %> 该文章在 2010/2/1 22:56:01 编辑过 |
关键字查询
相关文章
正在查询... |