【问题标题】:Upgrade to O365 broke EWS Autodiscover升级到 O365 破坏了 EWS 自动发现
【发布时间】:2018-06-30 15:30:06
【问题描述】:

我的公司刚刚将一些邮箱移动到 O365。不幸的是,这会破坏使用 EWS 创建的应用程序。在尝试调用 AutodiscoverUrl() 时,我遇到了一个错误。

'找不到自动发现服务。'

代码:

        service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        service.UseDefaultCredentials = true;
        service.AutodiscoverUrl(mailbox, RedirectionCallback);

        private bool RedirectionCallback(string url)
        {
            return true; 
        }

我也尝试将 URL 设置为以下

service.Url = new Uri("https://autodiscover.MYDOMAIN.com/autodiscover/autodiscover.xml");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

这些都没有解决问题。有谁知道从这里去哪里?

【问题讨论】:

    标签: c# exchangewebservices autodiscovery


    【解决方案1】:
    • service.UseDefaultCredentials 应该为 false,因为您需要电子邮件+密码(作为安全字符串)进行连接
    • 使用最新的 ExchangeVersion 值
    • 网址是https://outlook.office365.com/EWS/Exchange.asmx

      public ExchangeService Connect()
      {
          var lastExchangeVersion = Enum.GetValues(typeof(ExchangeVersion)).Cast<ExchangeVersion>().ToList().Last();
          var service = new ExchangeService(lastExchangeVersion)
          {
              Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"),
              Credentials = new NetworkCredential(_cloudEmail, _cloudPassword)
          };
          return service;
      }
      public SecureString ConvertStringToSecure(string password)
      {
          if (string.IsNullOrWhiteSpace(password)) return null;
          var result = new SecureString();
          foreach (char c in password) result.AppendChar(c);
          return result;
      }
      

    【讨论】:

      猜你喜欢
      • 2018-03-19
      • 1970-01-01
      • 2016-08-16
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多