我想查看我的hotmail帐户中除了收件箱之外的其他文件夹。
String host = "pop3.live.com";
String username = "peepants@hotmail.com";
String password = "peepantspants";
Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3s.port", "995");
Session session = Session.getInstance(pop3Props, null);
Store store = session.getStore("pop3s");
store.connect(host, 995, username, password);
Folder folder = store.getFolder("INBOX"); //this works fine
folder.open(Folder.READ_WRITE);
Folder[] f = store.getDefaultFolder().list("*");
for (int i = 0; i < f.length; i++ )
System.out.println( f[i].getFullName() ); //this only prints INBOX
Folder ofolder = store.getFolder("MyOtherFolder"); //this doesn't work
ofolder.open(Folder.READ_WRITE);
Message messages[] = folder.getMessages();
folder.copyMessages(new Message[]{messages[0]}, ofolder); //this doesn't work
除了收件箱,我无法进入任何其他文件夹。
store.getFolder("MyOtherFolder")
抛出以下错误
Exception in thread "main" javax.mail.FolderNotFoundException: folder is not INBOX
at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:199)
你不能。POP3协议仅支持单个邮箱。据我所知,Hotmail仍然不支持任何其他允许访问其他邮箱的标准协议,如IMAP。