I am using Exchange Web Api to subscribe new emails notification and I am getting the following error.
OnSubscriptionError : Microsoft.Exchange.WebServices.Data.ServiceResponseException: The specified subscription was not found.
Now, I want to simulate the behavior so that i know what can be done in the handler because i don't know whether i need to recreate the streaming object or i can use the already existing streaming object which is:
Subscription =
_exchangeService.SubscribeToStreamingNotifications(
new FolderId[] { WellKnownFolderName.Inbox },
EventType.NewMail);
Right now i have modified the code as below.
private void OnSubscriptionError(object sender, SubscriptionErrorEventArgs args)
{
if (args.Exception is ServiceResponseException)
{
var exception = args.Exception as ServiceResponseException;
Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL,
"OnSubscriptionError() : " + exception.Message + " Response: " + exception.Response +
"ErrorCode: " + exception.ErrorCode + " Stack Trace : " + exception.StackTrace +
" Inner Exception : " + exception.InnerException);
}
else
{
Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL,
"OnSubscriptionError() : " + args.Exception.Message + " Stack Trace : " +
args.Exception.StackTrace + " Inner Exception : " + args.Exception.InnerException);
}
try
{
Connection = (StreamingSubscriptionConnection)sender;
Connection.Open();
}
catch (ServiceResponseException exception)
{
Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL,
"OnSubscriptionError() : " + exception.Message + " Response: " + exception.Response +
"ErrorCode: " + exception.ErrorCode + " Stack Trace : " + exception.StackTrace +
" Inner Exception : " + exception.InnerException);
}
catch (Exception ex)
{
ExceptionThresholdExceeded(ex);
Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL, "OnSubscriptionError() : " + ex.Message + " Stack Trace : " + ex.StackTrace + " Inner Exception : " + ex.InnerException);
}
}