关于office 365的EWS web服务

本文关键字:web 服务 EWS office 关于 | 更新日期: 2023-09-27 18:03:16

我使用EWS web服务从office 365帐户获取电子邮件。我得到这个错误

无法找到自动发现服务。

我已经写好了这段代码。

ExchangeService service = new ExchangeService(userData.Version);
if (listener != null)
{
    service.TraceListener = listener;
    service.TraceFlags = TraceFlags.All;
    service.TraceEnabled = true;
}
service.Credentials = new NetworkCredential(userData.EmailAddress, userData.Password);
service.UseDefaultCredentials = false;
if (userData.AutodiscoverUrl == null)
{
    Console.Write(string.Format("Using Autodiscover to find EWS URL for {0}. Please wait... ", userData.EmailAddress));
    service.AutodiscoverUrl(userData.EmailAddress);
    userData.AutodiscoverUrl = service.Url;
    Console.WriteLine("Complete");
}

请检查我做错了什么。由于

关于office 365的EWS web服务

尝试如下:

ExchangeService service = new ExchangeService();
service.TraceEnabled = true;
service.Credentials = new WebCredentials(User, Pwd);
service.AutodiscoverUrl(User, RedirectionUrlValidationCallback);
service.TraceEnabled = true;