這可能是一個非常基本的問題,但我還沒有找到任何答案。我在Windows服務中使用Exchange Web服務來監控發送到我們的Exchange 2010服務器的新郵件,並使用訂閱服務。它工作得很好,很花哨,但問題在於服務器不可用(例如停電後),然後訂閱超時,Windows服務需要重新啓動。有沒有辦法在超時後更新訂閱,或者拉動EvenType.Status事件?EWS - 超時後續訂訂閱嗎?
這裏是我到目前爲止的代碼:
ExchangeService service;
PullSubscription subscriptionInbox;
private void SetService()
{
service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Url = new Uri("myurl");
service.Credentials = new WebCredentials(emailAddress, pass);
}
private void SetSubscription()
{
if (service == null)
{
SetService();
}
subscriptionInbox = service.SubscribeToPullNotifications(
new FolderId[] { WellKnownFolderName.Inbox },
5,
null,
EventType.NewMail, EventType.Modified);
}
private void DoStuff(object sender, EventArgs e)
{
GetEventsResults eventsInbox = subscriptionInbox.GetEvents();
EmailMessage message;
foreach (ItemEvent itemEvent in eventsInbox.ItemEvents)
{
//Do Stuff
}
}
任何想法,我可以怎麼用這個去?