EWS Push Notification Example Application

Note: I have written another sample application which does not use WCF (and also shows how to integrate easily with the EWS Managed API).  This sample is available here: http://blogs.msdn.com/b/emeamsgdev/archive/2012/12/20/ews-push-notification-sample.aspx

I had a case where a customer was having an issue with push notifications in an application, in that after a period of time the notifications stopped.  When I looked for an example push notification application for testing, I could not find any standalone applications – the current MSDN example requires IIS.

So, I wrote a standalone application demonstrating how push notifications can be implemented in a standalone application, which enabled me to effectively troubleshoot the customer’s problem.  The underlying problem was that under certain circumstances (e.g. application pool recycling) a subscription will be reset.  Any subscribed application needs to monitor for this eventuality and simply resubscribe if this happens.

The project is hosted at CodePlex: http://ewspushnotification.codeplex.com/

The solution consists of two projects, EWSPushListener and EWSPushTest.


This is a class library that implements the actual listener.  Once subscribed, notifications are collected and an event raised with the owning application (in this case EWSPushTest).

This library is not particularly complete, but shows how events can be handled.  I originally wanted to raise events with EWS Managed API objects, unfortunately this is not possible as the necessary classes cannot be inherited or overridden.  I therefore created new classes with equivalent structure to the managed API which makes handling them much easier.


This is the main application.  It shows how the listener should be initialised (which occurs as soon as the program is run) and also how to subscribe to events.  The application uses Autodiscover to determine the correct EWS URL, and also looks up the current user details in AD if necessary (this is the default).  The application subscribes to events from the given user’s calendar folder, so to test it simply set it running then create or modify appointments.  Any received events are logged to main window.

The code shows how the subscription can be monitored to ensure it is still active.  EWS will send a status message once per minute, and this can be used as a heartbeat to ensure everything is running smoothly.  The application uses a timer to ensure that a status message has been received recently – if it hasn’t, after a specific period the subscription will be reset.  The last watermark is used when re-subscribing so that no events are lost.

Comments (0)

Skip to main content