欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用EasyMailObject组件处理Exchange邮件源代码(3)

程序员文章站 2022-06-10 18:21:53
在asp中用easymailobject处理exchange邮件源代码---保存附件(saveatt.)<%@ language=vbscript %><%************...
在asp中用easymailobject处理exchange邮件源代码---保存附件(saveatt.)

<%@ language=vbscript %>
<%
*************************************

这个文件用来下载附件
作者:awayeah
邮箱:awayeah@163.net

*************************************


dim fso, tempfile
set fso = createobject("scripting.filesystemobject")
   dim tfolder, tname, tfile
   const temporaryfolder = 2
   set tfolder = fso.getspecialfolder(temporaryfolder)
set pop3=session("pop3")

   set pop3 = createobject("easymail.pop3.5")
   pop3.licensekey = "awa/s19i500r1ax30c0r3100"
   pop3.mailserver = strserver
   pop3.account = session("straccount")
   pop3.password = session("strpassword")
   pop3.preferredbodyformat=1
   pop3.timeout=90
   x = pop3.connect()
   if x <> 0 then
      response.write "连接错误: " + cstr(x)
      pop3.disconnect
   end if

设定附件存放的临时目录,要用绝对路径,这个目录应赋足够的权限给iusr_host帐户,并且已经web共享
   pop3.tempdirectory="e:webmailmailatt"
   y = pop3.downloadheaders
   i=clng(request.querystring("msgid"))
   j=clng(request.querystring("attid"))
   msg = pop3.downloadsinglemessage(i)
   set message object to point to that downloaded message
   set message = pop3.messages(msg)
   message.attachments(j).save tfolder+"/"+message.attachments(j).filename,1
   message.attachments(j).save "c:inetpub/wwwrootmailatt"+message.attachments(j).filename,1
   response.write "file:///"+"/mailatt/"+message.attachments(j).filename
   pathname=message.attachments(j).tempfilename
   parentfolder=fso.getparentfoldername(pathname)
   set folder=fso.getfolder(parentfolder)
   dir_name=folder.name
   filename=fso.getfilename(pathname)
   path="/webmail/mailatt/"+dir_name+"/"+filename
   response.redirect path
   %>