?? 09_06.jsp
字號:
<html>
<head>
<title>顯示所有e-mail列表</title>
</head>
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="javax.mail.*,java.util.*"%>
<body>
<center><h2>
顯示所有e-mail列表
</h2></center>
<%
try{
//獲得一個session對象,并設(shè)置其屬性為true
Properties props=new Properties();
Session recesession=Session.getInstance(props,null);
recesession.setDebug(true);
//創(chuàng)建一個Store對象,并根據(jù)得到的三個參數(shù)連接到郵件服務(wù)器中的用戶郵箱
Store store=recesession.getStore("pop3");
String host=request.getParameter("host");
String user=request.getParameter("user");
String password=request.getParameter("password");
store.connect(host,user,password);
//打開收件箱
Folder inbox=store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
//得到郵箱中的e-mail總數(shù)
int count=inbox.getMessageCount();
%>
<h3>收件箱中有<%=count%>封e-mail:</h3>
<%
//循環(huán)顯示所有的e-mail的標(biāo)題
for(int i=1;i<=count;i++)
{
Message message=inbox.getMessage(i);
//如果不是待刪除的e-mail就顯示出來
if(!message.isSet(Flags.Flag.DELETED))
{
String title=message.getSubject();
%>
<p>
(<%=i%>)  
標(biāo)題:<a href="09_08.jsp?msg=<%=i%>&host=<%=host%>&user=<%=user%>&password=<%=password%>"><%=title%></a>
</p>
<%
}
}
//關(guān)閉收件箱和到郵件服務(wù)器的連接
inbox.close(true);
store.close();
}catch(MessagingException m)
{
out.println(m.toString());
}
%>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -