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?