2
votes

I need to notify on events in thousands of mailboxes to another system, I've created a pull notification subscription and it works great, I've created several of them but I need to GetEvents() from each one separately, then I read this article How to: Maintain affinity between a group of subscriptions and the Mailbox server in Exchange in the MSDN, it says I need to add headers to the subscriptions then I'll be able to getEvents() for all of them in one request, using the EWS managed API it should look like this:

service.HttpHeaders.Add("X-AnchorMailbox", Mailbox.SMTPAddress);
service.HttpHeaders.Add("X-PreferServerAffinity", "true");

Then I should get back a cookie in the response:

X-BackEndOverrideCookie

I don't see the cookie in the response and I did not find anything in the article regarding how to obtain and use it in the EWS managed API (except those two lines above all the rest of the article is based on XML requests which I don't really like). besides that as far as the request it should include all the subscriptions id's (as seen in the XML) and for this I did not find a solution in the EWS managed API too. I've made this with the streaming notification solution but I would like to work with Pull notifications.

If anyone has any experience with this I would love to hear. Thanks in advance for the time you took in reading this and for your answers in case you've answered.

2
Is this for Office 365 or Exchange on-premises? If Exchange on-premises, which version of Exchange?Venkat Ayyadevara - MSFT
This is for Office365.Nadav
Thanks, I just posted an answer that might work for you for Office 365.Venkat Ayyadevara - MSFT

2 Answers

0
votes

For Office 365, have you looked at Webhooks through our Office 365 Mail, Calendar and Contacts REST API endpoint? See "Connect to the Outlook Service" on http://dev.outlook.com for more info. To access multiple mailboxes within an organization, you will need to use client credential flow.

As long as the system receiving the notifications has an always available endpoint to receive push notifications, that model works much better to monitor notifications from thousands of mailboxes. My recommendation would be to look at using Webhooks API. It is currently in Beta, but we are working actively to take it to GA. At that point, you can use Webhooks in production.

0
votes

I know this question was asked nearly three years ago, but I happen to be working on this today and hope this will help someone else.

I'm using streaming notifications, but I'm guessing it'll work similarly for pull notifications:

// You MUST send a subscription request first! Otherwise there won't be
// any cookies to examine.
exchangeService.SubscribeToStreamingNotifications(foldersToSubscribeTo, EventsToSubscribeTo);

// Get a string of all the cookies
var allCookies = exchangeService.CookieContainer.GetCookieHeader(exchangeService.Url);
Console.WriteLine(allCookies);

// Or get a specific cookie
var cookies = exchangeService.CookieContainer.GetCookies(exchangeService.Url);
var xBackEndOverrideCookie = cookies["X-BackEndOverrideCookie"];
Console.WriteLine(XBackEndOverrideCookie);

I think for new subscription requests where you were using a new exchange service, you would set the cookies like this:

exchangeService.CookieContainer.SetCookies(url, cookieHeader)

...but I could be wrong since I haven't had to actually set any cookies yet in my application.