如何通过javax.mail从hotmail中读取所有文件夹?

时间:2019-03-04 15:46:01

标签: java email hotmail

此代码仅找到INBOX文件夹。我需要阅读Sent Items文件夹。

public class Main {

    public static void main(String args[]) {
        String username = "xxxxxx@hotmail.fr";
        String password = "xxxxxx";
        try {
            String host = "pop3.live.com";
            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[] f = store.getDefaultFolder().list("*");
            for (Folder element : f) {
                System.out.println(element.getFullName()); // this only prints INBOX
            }

        } catch (Exception e) {
            System.err.println(e);
        }
    }
}

0 个答案:

没有答案