我正在尝试构建一个.NET应用程序,目的是从交换帐户中检索日历信息 . 我想检索有关资源的忙/闲信息 . 我将EWS .NET API与Exchange 2010连接一起使用 .
我可以检索诸如约会的StartTime和EndTime之类的信息,但是我无法获得其他信息,例如主题,CalendarEvents.Details中包含的位置 . 实际上,最后一个属性始终为null . 显然它可能是一个权限问题,但它不符合逻辑,因为我尝试使用自己的凭据读取自己的日历 .
//Exchange Connection
this.service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials(user, password, domain);
service.AutodiscoverUrl(this.email);
List<AttendeeInfo> attendees = new List<AttendeeInfo>();
//L'utilisateur déclaré dans l'objet, identifié par l'email
attendees.Add(new AttendeeInfo()
{
SmtpAddress = this.email,
AttendeeType = MeetingAttendeeType.Organizer
});
AvailabilityOptions myOptions = new AvailabilityOptions();
myOptions.MeetingDuration = 30;
myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;
GetUserAvailabilityResults freeBusyResults = service.GetUserAvailability(attendees,
new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)),
AvailabilityData.FreeBusy,
myOptions);
foreach (AttendeeAvailability availability in freeBusyResults.AttendeesAvailability)
{
foreach (CalendarEvent calendarItem in availability.CalendarEvents)
{
//The details here are always null :/
if (calendarItem.Details != null)
{
label3.Text = "Subject: " + calendarItem.Details.Subject +"\n";
label3.Text += " Location:" + calendarItem.Details.Location ;
}
label3.Text += "\n";
label3.Text += "Start:" + calendarItem.StartTime.TimeOfDay ;
label3.Text += "End:" + calendarItem.EndTime.TimeOfDay;
label3.Text += "\n";
panel1.BackColor = Color.PaleVioletRed;
break;
}
}
先感谢您,
1 回答
我有同样的问题,可能使用相同的示例代码 . 问题出在您的可用性选项的FreeBusyViewType中
myOptions.RequestedFreeBusyView = FreeBusyViewType.Detailed;
Link to MSDN Documentation