如何从 outlook 中的其他组和文件夹而不是收件箱下载或获取附件

how to download or get attachment from other groups and folders in outlook rather than inbox

我想从 outlook for office 中配置的特定文件夹和组中的特定邮件 ID 下载附件 我收到这个错误

我已经尝试将字符串从 INBOX 更改为其他文件夹,附件将保存在我本地机器上的一个文件夹中

Store store = session.getStore("pop3");
store.connect(userName, password);
Folder folderInbox = store.getFolder("payslip");
folderInbox.open(Folder.READ_ONLY);
Message[] arrayMessages = folderInbox.getMessages();

我收到以下错误

Could not connect to the message store
javax.mail.FolderNotFoundException: folder is not INBOX
    at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:192)
    at com.jcp.automation.EmailAttachmentReceiver.downloadEmailAttachments(EmailAttachmentReceiver.java:68)
    at com.jcp.automation.EmailAttachmentReceiver.main(EmailAttachmentReceiver.java:150)
log4j:WARN No appenders could be found for logger (com.jcp.automation.EmailAttachmentReceiver).
log4j:WARN Please initialize the log4j system properly.

我用的是imap而不是pop3 这里是代码

          properties.setProperty("mail.store.protocol", "imaps");
    properties.setProperty("mail.imaps.port", "993");
    Session session = Session.getDefaultInstance(properties);

    try {

        session = Session.getDefaultInstance(properties, null);

         javax.mail.Store store = session.getStore("imaps");


        store.connect("outlook.office365.com", "xyz", "xyz");
        Folder folderInbox = store.getFolder("james");
        folderInbox.open(Folder.READ_ONLY);