0
我成功地在Exchange郵箱中連接和接收郵件,但有時(我的意思是一天5次)連接失敗,拋出此異常:登錄失敗:未知用戶名或密碼錯誤。我不知道爲什麼有時它連接成功,沒有任何問題地完成工作,有時會失敗。以下是部分代碼:到Exchange Server SOMETIMES的連接錯誤失敗。爲什麼?
ExchangeService _service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
_service.Credentials = new WebCredentials("username", "password");
_service.AutodiscoverUrl("[email protected]");
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
FindItemsResults<Item> findResults = _service.FindItems(WellKnownFolderName.Inbox, new ItemView(1000));
Console.WriteLine("There are " + (findResults.Items.Count) + " emails in Inbox");
這段代碼有問題嗎?有什麼建議麼?