2014-11-23 47 views
1

我想獲得給定具體日期的所有約會。我檢查API,似乎只能得到特定用戶的委任嗎?獲取所有用戶的所有約會或獲得一個房間的所有約會

DateTime startDate = DateTime.Now; 
      DateTime endDate = startDate.AddDays(365); 
      const int NUM_APPTS = 5; 

      // Initialize the calendar folder object with only the folder ID. 
      CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()); 

      // Set the start and end time and number of appointments to retrieve. 
      CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS); 

      // Limit the properties returned to the appointment's subject, start time, and end time. 
      cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End); 

      // Retrieve a collection of appointments by using the calendar view. 
      FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView); 

      Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() + 
           " to " + endDate.Date.ToShortDateString() + " are: \n"); 

      foreach (Appointment a in appointments) 
      { 
       Console.Write("Subject: " + a.Subject.ToString() + " "); 
       Console.Write("Start: " + a.Start.ToString() + " "); 
       Console.Write("End: " + a.End.ToString()); 
       Console.WriteLine(); 
      } 

我希望可以得到所有約會或獲得特定房間的所有約會,然後我可以通過代碼提取信息。謝謝!

回答

0

使用EWS,findItems操作是針對每個郵箱文件夾完成的,所以如果您想查詢其他日曆,則需要執行多項操作。在你的代碼,如果你想查詢室郵箱具有[email protected]您需要使用FolderId超負荷如

FolderId cfFolderId = new FolderId(WellKnownFolderName.Calendar, "[email protected]"); 
CalendarFolder calendar = CalendarFolder.Bind(service, cfFolderId, new PropertySet()); 

乾杯 格倫

主SMTP地址
相關問題