[英]Unable to access calendar information from exchange server
我试图使用交换API从交换服务器获取日历信息,并且在遇到日历初始化错误时始终遇到以下错误:“ Exchange Server不支持请求的版本”。 我连接的服务器显然正在运行Exchange的混合版本。
我的代码如下:
ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials("user", "pass");
service.AutodiscoverUrl("url");
DateTime startDate = DateTime.UtcNow;
DateTime endDate = startDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
const int NUM_APPTS = 50;
//error happens on this line
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
cView.PropertySet = new PropertySet(AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location);
}
任何帮助将非常感激。 谢谢。
您需要设置访问https://msdn.microsoft.com/zh-cn/library/office/dn741586(v=exchg.150).aspx的ExchangeService对象的版本。 如果您只是想让它开始工作,我建议
new ExchangeService(ExchangeVersion.Exchange2007_SP1);
然后,您可以使用来查看服务器正在运行的版本
service.ServerInfo.VersionString属性
您也可以在创建对象之前使用自动发现来确定版本。 例如
AutodiscoverService adAutoDiscoverService = new AutodiscoverService();
adAutoDiscoverService.Credentials = ncCred;
adAutoDiscoverService.EnableScpLookup = true;
adAutoDiscoverService.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
adAutoDiscoverService.PreAuthenticate = true;
adAutoDiscoverService.TraceEnabled = true;
adAutoDiscoverService.KeepAlive = false;
GetUserSettingsResponse adResponse = adAutoDiscoverService.GetUserSettings("user@domain.com", (new UserSettingName[1] { UserSettingName.EwsSupportedSchemas }))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.