• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> ASP开发 >> 组件开发 >> 详细内容
 

推荐文章

 
 

热点文章

  • VB编写ActiveX DLL实现ASP编程
  • 汉字转换拼音(带音调)Asp版
  • 新生命Web服务器v1.1源码
  • VB编写ASP组件的调试
  • 使用ASPJPEG添加水印的方法
  • 用VB将ASP代码封装成DLL
  • 常见ASP组件介绍及下载
  • 用VB生成DLL封装ASP代码,连接数据库
  • 使用VB编写纯ASP程序
  • 调用winrar压缩文件夹
  • 利用OWC画图的例子
  • Asp生成条形码
 
 

相关文章

  • 一个用来画图的组件(画饼图,条形图,各种形状图象的
  • 利用OWC服务器端组件动态生成图表
  • 作一个可以直接和浏览器进行交互的组件
  • 一个用组件动态创建Excel文件的实例
  • 使用VC++6.0制作ASP服务器控件简介
  • 用VB创建FTP组件(get)
  • 用VB创建FTP组件(put)
  • 在WEB环境下打印报表的crystal的解决方案
  • 用ASP、VB和XML建立互联网应用程序
  • 如何制作无状态的ASP组件
  • 利用ASP改进文档上载控件
  • 利用ASP改进文档上载控件
 
 

百度搜索

 
 

在ASP中用EasyMailObject组件处理Exchange邮件源代码

  • 阅览次数:
  • 文章来源: 网海之贝
  • 原文作者: 佚名
  • 整理日期: 2006-10-03
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

读取邮件主题和大小(maillist1.asp)
<%@ LANGUAGE="VBSCRIPT" %>
<%
'************************************************

'这个文件列出所有邮件,并把邮件内容显示窗口置为空白窗口
'作者:awayeah
'邮箱:awayeah@163.net

'************************************************
%>
<script language=vbscript>
parent.frmbottom.location.href="blank.htm"
sub cmdel_onClick()
'删除邮件
frmail.submit
end sub
</script>
<%
if session("straccount")="" or session("strpassword")="" then
Response.write("<html><title>错误,尚未登录</title><body><p align=center><br><br>你尚未登录,请先退出登录!<br><br>")
Response.Write ("<a href='login.asp' target='_top'><img src='logout.jpg' border=0></a></p></body></html>")
Response.End
end if
%>
<html>
<head>
<title>收邮件</title>
</head>
<STYLE>
<!--
A{text-decoration:none}
-->
</STYLE>
<body bgcolor="#008080" text="#000000">
<%
'定义邮件服务器地址
strserver=session("strserver")
'定义帐号
strAccount=session("straccount")
'定义密码
strPassword=session("strpassword")
'设置组件的各种属性
  Set POP3 = CreateObject("EasyMail.POP3.5")
   POP3.LicenseKey = "awa/S19I500R1AX30C0R3100"
   POP3.MailServer = strServer
   POP3.Account = strAccount
   POP3.Password = strPassword
   pop3.PreferredBodyFormat=1
   pop3.TimeOut=120

   x = POP3.Connect
   If x <> 0 Then
      Response.Write "<p align=center>连接错误: " + CStr(x) + "<br><br>请和管理员联系"
      POP3.Disconnect
      Response.End
   End If

   x = POP3.DownloadMessages(0)
   If x <> 0 Then
      Response.Write "下载错误: " + CStr(x) +"<br><br>请和管理员联系"
      POP3.Disconnect
      Response.End
   End If%>
<p><br></p>
<form name="frmail" action="mail_prc.asp" method="POST">
<center>
<table border="1" width="580" cellspacing="0" cellpadding="0" bordercolor="#000080" bgcolor="#FFFFFF">
<tr><td colspan=6 align="center">
<%
'分页处理
if Request.QueryString("currentpage")="" then
cp=1
else
cp=Request.QueryString("currentpage")
end if
'得到邮件总数
m_count=POP3.Messages.Count
if m_count<=10 then
pagenum=1
sd=1
ed=m_count
else
pagenum=int(m_count/10)+1
if clng(cp)<>pagenum then
lastpage=m_count mod 10
sd=(clng(cp)-1)*10+1
ed=clng(cp)*10
else
sd=(clng(cp)-1)*10+1
ed=m_count
end if
end if
%>
你有<font color="ff00ff"><%=POP3.Messages.Count%></font>封邮件。</td>
<%session("msgcount")=POP3.Messages.Count%>
</tr>
<tr>
<td align="center" width="20">号</td>
<td align="center" width="120">来自/回复</td>
<td align="center" width="270">主题</td>
<td align="center" width="90">日期</td>
<td align="center" width="60">大小</td>
<td align="center" width="20">选择</td>
</tr>
    <%for i= sd to ed%>

<tr>
<td align="center" width="20"><%=i%></td>
<%
fw="回复:"+replace(POP3.messages.item(i).subject,space(1),"_")
%>
<td width="100">
<%receiver=POP3.Messages.item(i).from%>
<%if POP3.Messages.item(i).fromaddr="" then%>
<a href="">
<%else
%>
<a href=#  onClick=javascript:window.open('sendmail1.asp?addr=<%=pop3.messages.item(i).fromaddr%>&subject=<%=fw%>','sendnew','width=600,height=480,scrollbars=yes');>
<%end if%>
<%if trim(receiver)="" then
response.write "匿 名</a>"%>
<%else%>
<a href=#  onClick=javascript:window.open('sendmail1.asp?addr=<%=pop3.messages.item(i).fromaddr%>&subject=<%=fw%>','sendnew','width=600,height=480,scrollbars=yes');>
<font face="宋体" size="2">
<%=POP3.Messages.item(i).From%></font>
<%end if%>
</td>
<td width="270">

<%msgid=POP3.GetMessageID(i)%>
<a href="showbody1.asp?id=<%=msgid%>" target="frmbottom">
<font face="宋体" size="2">
<%
if trim(POP3.messages.item(i).Subject)="" then
response.write "无主题"
else
response.write POP3.messages.item(i).Subject
end if
%></font>
</a></td>
<td width="90"><font face="宋体" size="2"><%=cdate(mid(cstr(POP3.messages.item(i).date),6,11))%></font></td>

<td  width="60"><font face="宋体" size="2"><%=POP3.messages.item(i).size%></font></td>
<td><input type="checkbox" name="c<%=i%>" value="<%=i%>"></td>
</tr>
<%next
   POP3.Disconnect

%>
</table>
</center>
<p align="center"><input type="button" name="cmdel" value="删除"></p>
</form>
<div align="center">
<table border="1" cellspacing="0" cellpadding="0" bordercolor="#ff0080" bgcolor="#FFFFFF">
<tr><td>页数</td>
<%for i=1 to pagenum%>
<td><a href="maillist1.asp?currentpage=<%=i%>" target=frmtop> <%=i%> </a></td>
<%next%>
</tr></table></div>

</body>
</html>

 

读取邮件内容和附件(showbody1.asp)
<%@ LANGUAGE="VBSCRIPT" %>
<%
'************************************************

'这个文件显示邮件的内容和附件
'作者:awayeah
'邮箱:awayeah@163.net

'************************************************
%>

<html>
<head>
<title>读邮件</title>
</head>
<body>
<%
SET POP3=session("POP3")
   x = POP3.Connect()

   If x <> 0 Then
      Response.Write "连接错误: " + CStr(x)
      POP3.Disconnect
   End If
   y = POP3.DownloadHeaders
   j=pop3.GetMessageNumFromID(request.querystring("id"))
   msg = POP3.DownloadSingleMessage(j)
   'Set Message Object to point to that downloaded message
   Set Message = POP3.Messages(msg)
   '显示邮件内容
   Response.Write replace(Message.bodytext,chr(13),"<br>")
  %>
<%
'如果该邮件有附件,则显示附件文件名和文件大小
if message.Attachments.Count>0 then%>   
<P></p>
  <hr>
  <table border=1 align="left" cellspacing="0">
  <tr><td>文件名</td><td>大小</td><tr>
  <%
  For k = 1 To message.Attachments.Count
  Response.Write ("<tr><td>")%>
  <a href=# onClick=javascript:window.open('saveatt.asp?msgid=<%=j%>&attid=<%=k%>','getatt','width=600,height=440,scrollbars=yes');>
  <%=Message.Attachments(k).name%></a></td><td>
  <%Response.Write cstr(Message.Attachments(k).size)
  Response.Write "</td></tr>"
  Next
%>
</table>
<%
end if
POP3.Disconnect
%>
</body>
</html>

 

保存附件(saveatt.asp)
<%@ 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
   %>

删除邮件时调用的文件(mail_prc.asp)
<%@ Language=VBScript %>
<%
'*************************************

'这个文件是删除邮件时调用的
'作者:awayeah
'邮箱:awayeah@163.net

'*************************************

dim cc,cc1,sep,dd
'取得邮件总数
msgcount = session("msgcount")
sep=","

for i=1 to msgcount
dd="c"+cstr(i)
msgid=cstr(Request.Form (dd))
if msgid="" then
cc1=cc1+msgid
else
cc1=cc1+msgid+sep
end if
next

if len(cc1)=0 then
Response.Redirect "maillist1.asp"
end if
cc1=left(cc1,len(cc1)-1)
dim arr
arr=split(cc1,",")
   Set POP3 = CreateObject("EasyMail.POP3.5")
   pop3.account=session("straccount")
   pop3.password=session("strpassword")
   POP3.MailServer = "192.9.200.89"
   POP3.LicenseKey = "awa/S19I500R1AX30C0R3100"

   x = POP3.Connect()
for i=0 to ubound(arr)
arr(i)=clng(arr(i))
   y = POP3.DownloadHeaders

   '删除邮件

   x = POP3.DeleteSingleMessage(arr(i))

   If x <> 0 Then
'      Response.Write "<p align=center><br><br>删除邮件发生错误( " + CStr(x) + ").请与管理员联系.<br><br>"
'      Response.Write "<a href='maillist1.asp'>返回</a></p>"
      POP3.Disconnect
      Response.End
   Else
      'Response.Write "Message deleted successfully."
      'Response.Write ""
      'POP3.Disconnect
   End If
next
POP3.Disconnect
Response.Redirect "maillist1.asp"
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
</body>
</html>

发送邮件(p_sendmail.asp)
<%@ Language=VBScript %>
<%
'*************************************

'这个文件用来发送邮件
'作者:awayeah
'邮箱:awayeah@163.net

'*************************************

if session("straccount")="" or session("strpassword")="" then
Response.End
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<STYLE>
<!--
A{text-decoration:none}
-->
</STYLE>
<BODY>
<%   Set SMTP = CreateObject("EasyMail.SMTP.5")
   SMTP.LicenseKey = "awa/S19I500R1AX30C0R3100"
   SMTP.MailServer = "192.9.200.89"
   SMTP.Subject = Request.Form("subject")
   SMTP.BodyText = Request.Form("bodytext")
   SMTP.From = Request.Form("from")
   SMTP.FromAddr = Request.Form("fromaddr")
   SMTP.AddRecipient Request.Form("from"), Request.Form("receive1") , 1
   
   '添加附件
   if Request.Form("att")="" then
   Response.Write ""
   else
   x = SMTP.AddAttachment(Request.Form("att"), 0)
   If Not x = 0 Then
     Response.Write "插入附件错误: " + cstr(x) + "请与管理员联系。"
   End If
   end if
   x = SMTP.Send

   If x = 0 Then
'      Response.Write ("<P align=center><br><br>")
'     Response.Write ("<font size=")
      Response.Write "<p align='center'><br><br><b><font face='宋体' size='5' color='#00FFFF'><span style='background-color: #000080'>邮件已成功发出!</font></span></b>"
'      session("sended")="Y"
   Else
  if x=7 or x=5 then
      Response.Write "<br><br><p align='center'><b><font face='宋体' size='5' color='#00FFFF'><span style='background-color: #000080'>发邮件发生错误(" + cstr(x)+ ").发件人地址错误</span></font></b>"%>
       <br><br><input type="button" onclick="history.go(-1)"  value="返回">
      <%Response.End
  else
      Response.Write "<br><br><p align='center'><b><font face='宋体' size='5' color='#00FFFF'><span style='background-color: #000080'>发邮件发生错误: "   + cstr(x)+ "</span></font></b>"%>
       <br><br><input type="button" onclick="history.go(-1)"  value="返回" id=button1 name=button1>
      <%Response.End
  end if
  End If


   Set SMTP = Nothing
   
%>

<P align="center"> <a href="javascript:window.close();">
<font face="宋体" size="5"><b><span style="background-color: #FFFF00">返回</span></b></font></a></P>

</BODY>
</HTML>

 

发送邮件的界面(sendmail1.asp)
<%@ LANGUAGE="VBSCRIPT" %>
<%
'*************************************

'这个文件是发送邮件或回复邮件的界面
'作者:awayeah
'邮箱:awayeah@163.net

'*************************************


'取得回信地址
replyaddr=Request.QueryString("addr")
'取得要回邮件的主题
replysubj=replace(Request.QueryString("subject"),"_",space(1))
%>
<script language="vbscript">
sub CmdSubmit_onClick()
if trim(frmsendmail.receive1.value)="" then
alert ("尚未输入收件人地址,请输入!")
frmsendmail.receive1.focus
else
frmsendmail.submit
end if
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>发邮件</title>
</head>
<body bgcolor="#008080" text="#00FFFF">
<div span=1 align=center>
<form method="POST" action="p_sendmail.asp" name="frmsendmail">
  <table border="1" width="455" cellspacing="1" bgcolor="#800080">
    <tr>
      <td width="92">
        <p align="right"><b>发 件 人</b></p>
      </td>
      <td width="347"><input type="text" name="from" size="40"></td>
    </tr>
    <tr>
      <td width="92"><b>发件人邮箱</b></td>
      <td width="347"><input type="text" name="fromaddr" size="40"></td>
    </tr>
  </table>
  <table border="1" width="455" height="56" bgcolor="#000080">
    <tr>
      <td width="52" height="23">
        <p align="center"><b>收件人</b></p>
      </td>
      <td width="387" height="23">
        <p align="left"><input type="text" name="receive1" value="<%=replyaddr%>" size="40"></p>
      </td>
    </tr>
    <tr>
      <td width="52" height="23">
        <p align="center"><b>主 题</b></p>
      </td>
      <td width="387" height="23">
        <p align="left"><input type="text" name="subject" value="<%=replysubj%>" size="40"></p>
      </td>
    </tr>
    <tr>
      <td width="445" colspan="2" height="1">
        <table border="0" width="100%" height="184" cellspacing="0" cellpadding="0">
          <tr>
            <td width="8%" height="178">
        <p align="center"><b>内</b>
        <p align="center"> 
        <p align="center"><b>容</b>
              <p> </td>
            <td width="92%" height="178"><textarea rows="10" name="bodytext"  value="<%=bodytext%>" cols="55"></textarea></td>
          </tr>
        </table>
      </td>
<tr>     <td width="52">
    <p align="center"><b>附 件</b></p>
  </td>     <td width="387"><input type="file" name="att" size="20"></td></tr>
  </table>
  <p align="center"><input type="button" value="发送" name="cmdSubmit">   <input type="reset" value="全部重写" name="B2"></p>   
</form>   
</div>  
</body>   
   
</html>   

 

这些代码是针对Microsoft Exchange Server 5.5开发的,对服务器不一定可用,我在Imail 7.04上就用不了,可能是因为两个服务器对邮件的处理有点不同,譬如在Exchange上每个邮件都有一个唯一的ID,是不变的。但在Imail上就不一样了,它的邮件ID是可变的,譬如你有20封邮件,它就是从1排到20,如果你删掉了第17封,那第18封开始的ID就会自动减1。

保存附件的那个目录必须有足够的权限,而且必须WEB共享,当断开连接后那些临时文件会自动删除的,但在IMAIL里面就不行。

该组件的下载网址为:http://www.quiksoftcorp.com/
我用的是5.0的版本,最新版为6.0

 

上一篇:PHP编程技巧:看实例学正则表达式
下一篇:构建支持Master/Slave读写分离的数据库操作类
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号