0
我试图使用EWS-Api-2.1 nuget包开始与EWS合作。下面是简单的代码,我使用的是:与'autodiscover.domain.com'的连接失败使用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.
您是否知道交换服务器的IP或其DNS名称?然后,您可以尝试设置没有自动发现的连接。这可能会给你一个缩小原因的可能性。 – khlr
感谢您的意见,它帮助我解决问题。我添加了下一个代码:_service.Url = new Uri(“https://outlook.office365.com/EWS/Exchange.asmx”); –
你现在能够使用AutoDiscover? – khlr