我正在測試將電子郵件發送到我自己公司的電子郵件ID。我們有Outlook託管在Exchange服務器上。我用下面的代碼(有一個隨機更換我的電子郵件ID由於隱私原因):從C連接到Exchange時出現SSL/TLS錯誤#
using System;
using Microsoft.Exchange.WebServices.Data;
namespace TestEmail
{
class Program
{
static void Main(string[] args)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
//service.Credentials = new WebCredentials("[email protected]", "password");
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.AutodiscoverUrl("[email protected]", RedirectionUrlValidationCallback);
EmailMessage email = new EmailMessage(service);
email.ToRecipients.Add("[email protected]");
email.Subject = "Test mail";
email.Body = new MessageBody("Sending the test email");
email.Send();
}
private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
}
}
}
當我跑,我得到它說「AutodiscoverConfiguration失敗的錯誤:網絡異常(基礎連接被關閉:無法爲SSL/TLS安全通道的信任關係)
我不知道的Exchange服務器的安全性是如何在我的工作場所設置,因爲它是由不同的團隊來處理
怎麼辦。我解決了這個問題嗎?
感謝您的迴應! 我嘗試了您提到的Microsoft遠程連接測試,但仍然失敗。 正如你所建議的,我想我需要從Exchange管理員那裏獲得幫助。 – doodles
將是最好的選擇。如果需要,您可以[微調Exchange自動發現過程](http://www.admin-enclave.com/en/articles/exchange/267-speed-up-the-exchange-outlook-autodiscovery-process.html),但我不知道這是否適用於您的自創應用程序。 – BastianW