0

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?

drago
  • 1,129
  • 4
  • 22
  • 44

2 Answers2

2

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

1

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.

softveda
  • 10,282
  • 5
  • 40
  • 49