gpt4 book ai didi

c# - EWS - 超时后续订?

转载 作者:行者123 更新时间:2023-11-30 12:29:13 24 4
gpt4 key购买 nike

这可能是一个非常基本的问题,但我还没有找到任何答案。我在 Windows 服务中使用 Exchange Web 服务来监视通过请求订阅发送到我们的 Exchange 2010 服务器的新邮件。它工作得很好,但问题是如果服务器不可用(例如在断电后),然后订阅超时,Windows 服务需要重新启动。有没有办法在超时后续订订阅,或者拉取 EvenType.Status 事件?

到目前为止,这是我的代码:

    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
}
}

我有什么想法可以继续吗?

最佳答案

当您丢失订阅时,最好创建一个新订阅 - 而不要尝试恢复临时数据。您可以使用旧水印重新订阅,但成本过高。此链接提供了一些关于恢复与丢失订阅相关的通知的额外上下文:http://msdn.microsoft.com/en-us/library/office/dn458788(v=exchg.150).aspx#bk_recover .您可能还想观看第 9 channel 的视频,其中讨论了从丢失的订阅中恢复:http://channel9.msdn.com/Events/Open-Specifications-Plugfests/Windows-Identity-and-Exchange-Protocols-Plugfest-2012/Exchange-Web-Services-Best-Practices-Part-2 .

关于c# - EWS - 超时后续订?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19295372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com