gpt4 book ai didi

JavaMail Hotmail 获取文件夹列表

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:44 26 4
gpt4 key购买 nike

我想查看我的 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 协议(protocol)只支持单个邮箱。据我所知,Hotmail 仍然不支持任何其他允许访问其他邮箱的标准协议(protocol),例如 IMAP。

关于JavaMail Hotmail 获取文件夹列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8763382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com