欢迎光临
我们一直在努力

使用asp实现支持附件的邮件系统(三)

建站超值云服务器,限时71元/月

最后,我们来讲讲如何把内容从数据库中读出来,内容有这么几类,一类是浏览器上可以显示的,例如*.htm,一类是需要下载的,例如*.exe,还有一种是浏览器可以显示但是不能够让他显示的,例如*.asp,请看代码:

<%
response.buffer= true
response.clear

function getname(oriname)
   thename=oriname
   do while instr(thename,"/")>0
           thename=mid(thename,instr(thename,"/")+1)
   loop
   do while instr(thename,"\")>0
           thename=mid(thename,instr(thename,"\")+1)
   loop
   getname=thename

end function

function canexec(thechar)
   if instr(thechar,".asp")>0 then
         canexec=false
         exit function
   end if
   if instr(thechar,".asa")>0 then
         canexec=false
         exit function   
   end if
   if instr(thechar,".aspx")>0 then
         canexec=false
         exit function   
   end if
   if instr(thechar,".asax")>0 then
         canexec=false
         exit function   
   end if
   canexec=true
end function
mailid=request("mailid")
se=request("se")
if se<>1 and se<>2 and se<>3 then
response.end
end if
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "dsn=;uid=;pwd="
sql="select * from t_mail  where ((geterempl like %"&session("myid")&"% or deleempl like %"&session("myid")&"% or receempl like %"&session("myid")&"% ) and (not deleverempl like %"&session("myid")&"%)) and mailid="&mailid&" "           
rs.open sql,conn,3,3
if rs.eof or rs.bof then
response.end
end if
  if rs("filecontenttype_"&trim(se))<>"text/plain" or (not canexec(getname(trim(rs("filename_"&trim(se)))))) then
    response.contenttype = rs("filecontenttype_"&trim(se))
  end if
        

  response.addheader "content-type","application/x-msdownload"
  
   if instr(response.contenttype,"application")>0 then
     response.addheader "content-disposition","attachment;filename="&getname(trim(rs("filename_"&trim(se))))
   end if  
  response.binarywrite rs("filecontent_"&trim(se))
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

文章到这里就结束了,至于邮件数据库的数据结构大家根据代码自己琢磨吧!

                            ———–sonic

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 使用asp实现支持附件的邮件系统(三)
分享到: 更多 (0)

相关推荐

  • 暂无文章