当我在 MS Exchange 中收到新邮件时,在 Java 应用程序中启动方法的选项有哪些?有某种网络服务吗?或者我可以从 Outlook 文件夹中获取它吗?或者我应该像这样使用 Java Mail - 每隔几秒钟检查一次收件箱文件夹:
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("<impap_address>","<mail ID> ", "<Password>");
inbox = store.getFolder("Inbox");
System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
inbox.open(Folder.READ_ONLY);
/* Get the messages which is unread in the Inbox*/
Message messages[] = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
这对我来说看起来最自然,但 IMAP 目前在公司 Exchange 服务器上没有激活,我想找到其他方法来解决这个问题。
还有其他选择吗?