六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 159|回复: 0

ASP通过JMail组件读取邮件列表

[复制链接]

升级  27.33%

23

主题

23

主题

23

主题

秀才

Rank: 2

积分
91
 楼主| 发表于 2013-2-7 22:19:20 | 显示全部楼层 |阅读模式
<html>
<style type="text/css">
<!--
body,td,th {
 font-size: 9pt;
}
-->
</style>
<body>  
<table width="800" border="0" cellspacing="1" cellpadding="5">
<form name="form1" method="post" action="">
    <tr>
      <td colspan="5" align="center"><h2>ASP通过JMail组件读取邮件列表</h2></td>
    </tr>
    <tr>
      <td>邮箱:
          <select name="pop3Server">
            <option value="pop.163.com" selected>163邮箱</option>
            <option value="pop.126.com">126邮箱</option>
</select>
      </td>
      <td>邮箱的登录名:
      <input name="uid" type="text" id="uid" size="15" maxlength="30"></td>
      <td>邮箱的登录密码:
      <input name="upwd" type="password" id="upwd" size="15" maxlength="30"></td>
      <td>日期:
      <input name="riqi" type="text" id="riqi" value="2010-03-17" size="12" maxlength="20"></td>
      <td><input type="submit" name="submit" id="submit" value="提交"></td>
    </tr>
    </form>
  </table>
  <table width="800" border="1" cellspacing="0" cellpadding="5">
      <tr align="center">
      <td><strong>序号</strong></td>
      <td><strong>日期</strong></td>
      <td><strong>邮件标题</strong></td>
      <td><strong>发件人</strong></td>
      <td><strong>附件</strong></td>
      <td><strong>内容</strong></td>
    </tr>
<%
if request.Form("submit")<>"" then
pop3Server=request.Form("pop3Server")
uid=request.Form("uid")
upwd=request.Form("upwd")
riqi=CDate(request.Form("riqi"))
Set pop3 = Server.CreateObject( "JMail.POP3" )
pop3.Connect uid, upwd, pop3Server  
'Response.Write( "你有" & pop3.count & " 封邮件。<br><br>" )
'set msg=server.CreateObject("jmail.message")
Function getAttachments() '获得附件
 if Attachments.Count>0 then
   Set Attachments = msg.Attachments
  getAttachments = Attachments(0).Name & "(" & Attachments(0).Size & " bytes)"
 else
 getAttachments=""
 end if
  End Function  
for i=1 to pop3.count
 Set msg = pop3.Messages.item(i)
 Set Attachments = msg.Attachments
 if CDate(msg.date)>=riqi then%>
    <tr>
      <td align="center"><%= i %></td>
      <td align="center"><%= msg.date %></td>
      <td><%= msg.Subject %></td>
      <td><%= msg.FromName %> </td>
      <td><%= getAttachments %> </td>
      <td><%'=left(msg.Body,50) %> </td>
    </tr>
  <%end if
  next
  pop3.Disconnect
end if%>
</table>
  </body>
  </html>
 
在线演示:http://www.aspok.net/yanshi/aspreadmail.asp
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表