These are chat archives for OfficeDev/ews-java-api

29th
Apr 2018
phiphuc
@phiphuc
Apr 29 2018 08:40

hello guys, im using push notification subscribe :

System.out.println("START MAIL EXCHANGE");
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx"));
            ExchangeCredentials credentials = new WebCredentials(username, passworrd, "outlook.office365.com");
            service.setCredentials(credentials);

            URI uri = new URI("http://localhost:8087/api/mail");

            WellKnownFolderName wkFolder = WellKnownFolderName.Inbox;
            FolderId folderId = new FolderId(wkFolder);
            List<FolderId> folder = new ArrayList<FolderId>();
            folder.add(folderId);
            PushSubscription subscription = service.subscribeToPushNotifications(
                folder, uri , 1, null,
                EventType.NewMail, EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved);
            /*IAsyncResult result = service.beginSubscribeToPushNotifications(null, null, folder, uri, 1, null, EventType.NewMail, EventType.Created, EventType.Deleted);
            PushSubscription subscription1 = service.endSubscribeToPushNotifications(result);*/
            System.out.println("END MAIL EXCHANGE");
        } catch (Exception e) {
            System.out.println("EXCEPTION MAIL EXCHANGE");
            e.printStackTrace();
        }

Then my Listener :
@PostMapping(value = "/mail", consumes = MediaType.TEXT_XML_VALUE)
@Timed
public void mailExchange(HttpServletRequest request, HttpServletResponse response){
log.debug("---------- MAIL_EXCHANGE_LISTERNER SUECCESS ----------");

}
i set break point in log.debug("---------- MAIL_EXCHANGE_LISTERNER SUECCESS ----------"); .when i sent email nothings happens. please help me