【问题标题】:EWS - Renew subscription after timeout?EWS - 超时后续订订阅?
【发布时间】:2013-10-18 04:33:25
【问题描述】:

这可能是一个非常基本的问题,但我还没有找到任何答案。我在 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
        }
    }

有什么想法可以继续吗?

【问题讨论】:

    标签: c# exchangewebservices exchange-server-2010


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-02-27
      • 1970-01-01
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 2013-06-30
      相关资源
      最近更新 更多