我需要在工作場所設置自定義應用程序,以便從特定Exchange Server郵箱讀取電子郵件主題行,並根據內容重定向它們。我寫了下面的代碼來測試連接:無自動發現連接到Exchange?
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;
}
}
}
}
但是工作場所的安全設置不允許暴露自動發現端點和筆者獲悉,該設置不能更改。
有沒有其他方法可以讓我連接到Exchange服務器,而不使用AutoDiscover?
這是一個跟進我剛纔的問題SSL/TLS error when connecting to Exchange from C#