Exchange Web 服务:请求失败。基础连接已关闭:接收时发生意外错误
Exchange Web services :The request failed. The underlying connection was closed: An unexpected error occurred on a receive
我收到此错误:T请求失败。基础连接已关闭:接收时发生意外错误。
当我尝试使用 EWS 从交换服务器读取电子邮件时
这是我的代码:
try {
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ServicePointManager.MaxServicePoints =1000;
ServicePointManager.MaxServicePointIdleTime = 10000;
ServicePointManager.UseNagleAlgorithm = true;
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 10000;
var exchange = new ExchangeService(ExchangeVersion.Exchange2013);
exchange.Credentials = new WebCredentials("user", "password", "domain");
exchange.TraceEnabled = true;
exchange.TraceFlags = TraceFlags.All;
exchange.AutodiscoverUrl("mail-id", RedirectionUrlValidationCallback);
exchange.Url = new System.Uri("https://URL/EWS/Exchange.asmx");
exchange.KeepAlive = false;
exchange.Timeout = 900000;
WriteToFile("Connected to Exchange Server : " + exchange.Url.Host);
TimeSpan ts = new TimeSpan(0, 0, -15, 0);
DateTime date = DateTime.Now.Add(ts);
SearchFilter.IsGreaterThanOrEqualTo filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, date);
if (exchange != null)
{
FindItemsResults<Item> findResults = exchange.FindItems(WellKnownFolderName.Inbox, filter, new ItemView(999));
foreach (Item item in findResults)
{
EmailMessage message2 = EmailMessage.Bind(exchange,
(EmailMessage.Bind(exchange, item.Id)).Id,
new PropertySet(BasePropertySet.FirstClassProperties,
new ExtendedPropertyDefinition(0x1013, MapiPropertyType.Binary)));
var mailbosy = message2.Body.Text;
}
我确认@Glen Scales 所说的。 MSI 下载和 NuGet 下载不起作用。您必须从源代码重新编译。
我收到此错误:T请求失败。基础连接已关闭:接收时发生意外错误。
当我尝试使用 EWS 从交换服务器读取电子邮件时 这是我的代码:
try {
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ServicePointManager.MaxServicePoints =1000;
ServicePointManager.MaxServicePointIdleTime = 10000;
ServicePointManager.UseNagleAlgorithm = true;
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 10000;
var exchange = new ExchangeService(ExchangeVersion.Exchange2013);
exchange.Credentials = new WebCredentials("user", "password", "domain");
exchange.TraceEnabled = true;
exchange.TraceFlags = TraceFlags.All;
exchange.AutodiscoverUrl("mail-id", RedirectionUrlValidationCallback);
exchange.Url = new System.Uri("https://URL/EWS/Exchange.asmx");
exchange.KeepAlive = false;
exchange.Timeout = 900000;
WriteToFile("Connected to Exchange Server : " + exchange.Url.Host);
TimeSpan ts = new TimeSpan(0, 0, -15, 0);
DateTime date = DateTime.Now.Add(ts);
SearchFilter.IsGreaterThanOrEqualTo filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, date);
if (exchange != null)
{
FindItemsResults<Item> findResults = exchange.FindItems(WellKnownFolderName.Inbox, filter, new ItemView(999));
foreach (Item item in findResults)
{
EmailMessage message2 = EmailMessage.Bind(exchange,
(EmailMessage.Bind(exchange, item.Id)).Id,
new PropertySet(BasePropertySet.FirstClassProperties,
new ExtendedPropertyDefinition(0x1013, MapiPropertyType.Binary)));
var mailbosy = message2.Body.Text;
}
我确认@Glen Scales 所说的。 MSI 下载和 NuGet 下载不起作用。您必须从源代码重新编译。