我尝试使用EWS-Api-2.1 nuget包开始使用EWS。以下是我使用的简单代码:
ExchangeService _service = new ExchangeService();
_service.Credentials = new WebCredentials("mail", "password");
_service.AutodiscoverUrl("mail", url => false);//_service.AutodiscoverUrl("mail") Both variants fails
var appointment = new Appointment(_service);
appointment.Subject = "Status Meeting";
appointment.Body = "The purpose of this meeting is to discuss status.";
appointment.Start = DateTime.Now.AddHours(1);
appointment.End = appointment.Start.AddHours(2);
appointment.Location = "Conf Room";
appointment.RequiredAttendees.Add("mail1");
appointment.Save(SendInvitationsMode.SendToNone);
结果我有:
HTTP/1.1 502 Fiddler - Connection Failed
[Fiddler] The connection to 'autodiscover.domain.com' failed.
Error: ConnectionRefused (0x274d). System.Net.Sockets.SocketException
No connection could be made because the target machine actively refused it 157.56.248.169:443
在DNS管理中,我有以下内容:
Initial domain: This domain is included with your account. It’s set up automatically for you, and you can’t delete it.
答案 0 :(得分:1)
如果您想了解自动发现失败的原因,我建议enabling tracing使用所有与自动发现相关的跟踪标记。当然我假设你传递的那个“邮件”实际上是用户的电子邮件地址。