获取所有用户的所有约会或获得一个房间的所有约会

时间:2014-11-23 07:32:39

标签: exchangewebservices

我想让所有约会给出具体的约会日期。我检查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();
            }

我希望可以获得所有约会或获得特定房间的所有约会,然后我可以通过代码提取信息。谢谢!

1 个答案:

答案 0 :(得分:0)

使用EWS,findItems操作按邮箱文件夹完成,因此如果您想查询其他日历,则需要执行多项操作。在您的代码中,如果您要查询具有主要SMTP地址room@domain.com的会议室邮箱,则需要使用FolderId重载,例如

FolderId cfFolderId = new FolderId(WellKnownFolderName.Calendar, "Room@doman.com");
CalendarFolder calendar = CalendarFolder.Bind(service, cfFolderId, new PropertySet());

干杯 格伦

相关问题