<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