Exception in Exchange Web Service while getting new message events RRS feed

  • Question

  • Hi,

    I have written sample application (in c#) which sends email to one user using Exchange Web Services and waits for response email (sent using inbox rule).

    To check if expected response email is received or not I am using PullSubscription::GetEvents() method. Below is the code I used.

    PullSubscription subscription = ews.SubscribeToPullNotifications(new FolderId[] { WellKnownFolderName.Inbox, WellKnownFolderName.JunkEmail, WellKnownFolderName.MsgFolderRoot, WellKnownFolderName.SentItems }, 1, null, EventType.NewMail);

    GetEventsResults events = subscription.GetEvents();

    PullSubscription::GetEvents() method works fine sometime, but sometimes throws exception. Below is the exception.

    Microsoft.Exchange.WebServices.Data.ServiceResponseException: The specified subscription was not found.
       at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.GetEvents(String subscriptionId, String watermark)
       at Microsoft.Exchange.WebServices.Data.PullSubscription.GetEvents()

    Every time I using same user to connect to Exchange Web Service.

    Does anybody knows when this exception is thrown? And why same method works fine sometime, but throws exception sometimes?

    Any help in this regards will be appreciated.

    Thanking in advance and Regards,

    Rohit Ekbote

    Wednesday, May 30, 2012 2:20 PM