///
/// 获取用户在某段时间内的所有会议。最长时间间隔为42天。
///
/// 要查询的开始时间。
/// 要查询的结束时间
/// 要查询的邮箱日历,如果查询当前登录的用户的日历,可不填。
/// 返回一个会议列表。列表对象不包含详细信息(如接受拒绝状态等),需使用 方法获取。
public List GetMeetings(DateTime startDate, DateTime endDate, string mailbox = null)
{
CalendarFolder calendar = null;
if (mailbox == null)
{
calendar = CalendarFolder.Bind(Service, WellKnownFolderName.Calendar);
}
else
{
FolderId folderid = new FolderId(WellKnownFolderName.Calendar, mailbox);
calendar = CalendarFolder.Bind(Service, folderid);
}
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate);
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.LastModifiedTime,
AppointmentSchema.IsMeeting,
AppointmentSchema.Start,
AppointmentSchema.End);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults appointments = calendar.FindAppointments(cView);
return appointments.Where(m => m.IsMeeting).ToList();
}