Get all appointments of all users or get all appointments of one room

♀尐吖头ヾ 提交于 2019-12-08 04:30:06

问题


I would like to get all appointments giving a specific date peroid. I check the API, it seems only can get appointnments for a specific user?

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();
            }

I hope can get all appointments or get all appointments for a specific room, then I can extract info by code. Thanks!


回答1:


With EWS the findItems operation is done per Mailbox Folder so if you want query other calendars you need to do multiple operations. In your code if you wanted to query the Room Mailbox that had a Primary SMTP Address of room@domain.com you need to use the FolderId overload eg

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

Cheers Glen



来源:https://stackoverflow.com/questions/27086634/get-all-appointments-of-all-users-or-get-all-appointments-of-one-room

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!