我正在尝试连接到Office 365邮箱以通过C#获取日历信息。
我收到以下错误:The Autodiscover service couldn't be located
。
我的代码:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials(username, password, domain);
service.AutodiscoverUrl(emailid, RedirectionCallback);
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
service.LoadPropertiesForItems(appointments, PropertySet.FirstClassProperties);
RedirectionCallback函数
static bool RedirectionCallback(string url)
{
// Return true if the URL is an HTTPS URL.
return url.ToLower().StartsWith("https://");
}