利用W3 JMAIL组件收POP3邮件

作者:网络 来源:佚名 更新时间:2008-11-23 17:18:58 点击:
<% @language=vbscript %>
<%

dim startpage
dim endpage
startpage=int(request("start"))
endpage=int(request("end"))

set pop3 = server.createobject( "jmail.pop3" )

uid=trim(request("uid"))
pwd=trim(request("pwd"))
pop=trim(request("pop"))

if uid="" or pwd="" or pop="" then
response.redirect "receivemail.asp"
end if


if uid<>"" and pwd<>"" and pop<>"" then
response.cookies("uid")=trim(request("uid"))
response.cookies("pwd")=trim(request("pwd"))
response.cookies("pop")=trim(request("pop"))
else
uid=request.cookies("uid")
pwd=request.cookies("pwd")
pop=request.cookies("pop")
end if
pop3.connect uid, pwd,pop

'pop3.connect "agang0084", "921028", "pop3.sina.com.cn"
response.write "<div align=center>"
response.write( "您的收件箱有 <font color=red>" & pop3.count & "</font> 封邮件<br><br>" )
response.write "</div>"



'计算页数
pagenum=10 '一页共存几条记录
if pop3.count<pagenum then
pagecount=1
else
intcount=int(pop3.count/pagenum)
modcount=pop3.count mod pagenum
if modcount>0 then
pagecount=intcount+1 '如果总记录除以一页可存放的记录数有余数则页数必须加以一
else
pagecount=intcount
end if
end if

response.write ("您的邮件共有"&pagecount&"页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")


'计算页码

page=trim(request("page"))
if page<>"" then
select case page
case "firstpage"
startpage=1
endpage=pagenum
case "lastpage"
startpage=(pagecount-1)*pagenum+1
endpage=pop3.count
case "next"
if endpage+10 > pop3.count then
startpage=(pagecount-1)*pagenum+1
endpage=pop3.count
else
startpage=startpage+10
endpage=endpage+10
end if
case "back"
if startpage=pagenum+1 then
startpage=1
endpage=pagenum
else
startpage=startpage-10
endpage=endpage-10
end if
end select
else
if pop3.count<pagenum then
startpage=1
endpage=pop3.count
else
startpage=1
endpage=pagenum
end if
end if



if pop3.count > 0 then
dim msg(20)
dim attachments(20)
for i=1 to pop3.count
set msg(i) = pop3.messages.item(i)
set attachments(i) = msg(i).attachments
next
%>
<%
if startpage=1 then
response.write "第一页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
else
response.write "<a href=pop3.asp?page=firstpage&start="&startpage&"&end="&endpage&">第一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
end if

if endpage=pop3.count then
response.write "下一页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
else
response.write "<a href=pop3.asp?page=next&start="&startpage&"&end="&endpage&">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
end if

if startpage=1 then
response.write "上一页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
else
response.write "<a href=pop3.asp?page=back&start="&startpage&"&end="&endpage&">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
end if

if endpage=pop3.count then
response.write "最后一页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
else
response.write "<a href=pop3.asp?page=lastpage&start="&startpage&"&end="&endpage&">最后一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
end if

response.write "当前记录是从第"
response.write startpage
response.write "封到"
response.write endpage
response.write &

||| quot;封的信件"
response.write "<br>"
response.write "<br>"
%>


<html>
<link rel="stylesheet" href="../../css/css.css" type="text/css">


<body bgcolor="eeeeee">
<table width="100%" cellpadding="0" cellspacing="0" border="1" bordercolor="#eeeeee">
<% for i=startpage to endpage %>
<tr>
<td width="11%" bordercolor="#333333">主题:</td>
<td width="77%" bordercolor="#333333">&nbsp;<%= msg(i).subject %></td>
<td width="12%" bordercolor="#333333">
<div align="center"><a href="../deletemail.asp?messageid=<%=i%>">删除</a></div>
</td>
</tr>
<tr>
<td width="11%" bordercolor="#333333">发件人:</td>
<td colspan="2" bordercolor="#333333">&nbsp;<a href="test_sendmail.asp?mailto=<%=msg(i).from%>"><%= msg(i).from %></a>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff0000">点击地址回复信件</font></td>
</tr>
<tr>
<td width="11%" bordercolor="#333333">附件个数:</td>
<td colspan="2" bordercolor="#333333">&nbsp;<%= attachments(i).count %>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff0000">接收附件</font></td>
</tr>
<tr>
<td width="11%" bordercolor="#333333">正文:</td>
<td colspan="2" bordercolor="#333333">&nbsp;<%= msg(i).body %></td>
</tr>
<tr>
<td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
<% next
%>
</table>

</body>
</html>
<%

end if

pop3.disconnect

%>

国内最大的酷站演示中心!