簡體   English   中英

升級到O365破壞了EWS自動發現

[英]Upgrade to O365 broke EWS Autodiscover

我公司只是將一些郵箱移至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");

這些都沒有解決問題。 有人知道從這里去哪里嗎?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM