使用C#通过EWS API访问Office 365日历

时间:2016-09-15 21:19:00

标签: c# exchangewebservices

我正在尝试连接到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://");
}

0 个答案:

没有答案