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