Retrieving mails from MS Exchange Server from Java application

女生的网名这么多〃 提交于 2019-12-12 04:03:57

问题


What are the options for starting a method in Java app when I receive a new mail in MS Exchange? Is there some kind of web service for this? Or can I get it from the Outlook folder? Or should I use Java Mail like this - checking inbox folder every few seconds:

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));

This one looks the most natural to me but IMAP is not currently activated on the company Exchange server and I would like to find some other way to solve this.

And are there other options?


回答1:


Look for Java APIs called JWebDAV and JWebServices for Exchange. It is Java implementation of WebDAV and EWS protocol.




回答2:


Exchange has webservices but as a .Net developer I have only used it using the official SDK which is a wrapper over the webservices. Exchange 2003 and 2007 has a webdav interface but it has been removed in 2010. Both the methods should be agnostic of client technology used but I have no first hand experience of using it from Java.



来源:https://stackoverflow.com/questions/11612516/retrieving-mails-from-ms-exchange-server-from-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!