Receive all notifications from an Exchange 2010 server immediately using EWS

I am currently using the EWS Managed API to subscribe to Pull Notification on an Exchange 2010 server to receive calendar item notifications, and it works fine. As I did this, I got a list of users with their email from the SQL database, and then quoted each of them and signed each of them to Pull Notification using SubscribeToPullNotifications() and then GetEvents() . I subscribe to Created , Modified and Deleted events in the Calendar folder.

I think that this is the best way to receive all notifications from the Exchange server, except that each user will loop over each user, because at all times all users have notifications, only the user if they create, update or delete items in their calendar in MS Outlook will have an event fired from the Exchange server.

For example, 200 users are retrieved from the SQL database, but only 10 of them create a new appointment in MS Outlook, but since I loop each of them, I need to have 200 cycles to receive 10 notifications from this 10 users.

Is there a way to get all notifications from the Exchange server at any time so that you don’t have to iterate over all users to find out if there is any event from the Exchange server? I know it might be better to use Push or Streaming Notification, but I would like to know if there is a better way to do this using Pull Notification?

Thanks.

+4
source share
1 answer

An EWS subscription is tied to one mailbox - you cannot subscribe to several stores yet (tested on Exchange 2010).

You can subscribe to several folders in the mailbox using SubscribeToPullNotifications() , passing in IEnumerable<FolderId> for all mailbox folders (Inbox, Sent Items, etc.) that you want to subscribe to.

You will need to use a delegate account that has access to all user mailboxes, which is similar to what you already have.

 FolderId folder1 = new FolderId(WellKnownFolderName.Calendar, new Mailbox(" email@email.com ")); FolderId folder2 = new FolderId(WellKnownFolderName.Calendar, new Mailbox(" email2@email.com ")); var folderIds1 = new FolderId[] { folder1 }; var folderIds2 = new FolderId[] { folder2 }; var trackedEvents = new EventType[] { EventType.Deleted, EventType.Created, EventType.Modified } PullSubscription subscription1 = service.SubscribeToPullNotifications(folderIds1,10,null,trackedEvents); PullSubscription subscription2 = service.SubscribeToPullNotifications(folderIds2,10,null,trackedEvents); // call subscrition.GetEvents() to retrieve new entries GetEventsResults subEvents1 = subscription1.GetEvents(); GetEventsResults subEvents2 = subscription2.GetEvents(); 
+5
source

Source: https://habr.com/ru/post/1397358/