2

我正在尝试构建一个 .NET 应用程序,目的是从交易所帐户中检索日历信息。我想检索有关资源的忙/闲信息。我将 EWS .NET API 与 Exchange 2010 连接一起使用。

我可以检索约会的开始时间和结束时间等信息,但我无法获取其他信息,例如主题、CalendarEvents.Details 中包含的位置。实际上,最后一个属性始终为空。显然这可能是权限问题,但这不合逻辑,因为我尝试使用自己的凭据阅读自己的日历。

//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;       
         }
    }

先感谢您,

4

1 回答 1

4

我有同样的问题,可能使用了相同的示例代码。问题在于您的可用性选项的 FreeBusyViewType

myOptions.RequestedFreeBusyView = FreeBusyViewType.Detailed;

链接到 MSDN 文档

于 2013-09-17T21:03:25.803 回答