C# exchange server 获取会议室预约列表

C# exchange server get meeting room appointment list

我正在尝试与 EWS Managed API 一起获取会议室列表, 并为每个房间查看一周的预约列表。

我看到了Get room lists by using EWS in Exchange 并且 Get appointments and meetings by using EWS in Exchange

我测试了第一个 link,我得到了 0 个房间。
同样对于第二个 link 它提供了当前用户日历但没有会议。

我需要 3 样东西:

1) 获取我组织中的会议室列表。
2) 获取每个房间的会议日历(X 天)。
3) 对于每次会议,谁组织了会议。

我找不到获取此信息的 API。

经过大量搜索并感谢 this post 我找到了问题 #1 和 #2

的答案

1) 获取组织中的所有会议室:

 string filter = "(&(objectClass=*)(msExchRecipientDisplayType=7))";
 //Assembly System.DirectoryServices.dll
 DirectorySearcher search = new DirectorySearcher(filter);
 List<AttendeeInfo> rooms = new List<AttendeeInfo>();  
 foreach (SearchResult result in search.FindAll())
            {
                ResultPropertyCollection r = result.Properties;
                DirectoryEntry entry = result.GetDirectoryEntry();
                // entry.Properties["displayName"].Value.ToString() will bring the room name
                rooms.Add(new AttendeeInfo(entry.Properties["mail"].Value.ToString().Trim()));                 
            }

2) 获取每个房间的会议日历(2 天):

List<AttendeeInfo> attend = new List<AttendeeInfo>();
foreach (AttendeeInfo inf in rooms)
     {
       attend.Clear();
       attend.Add(inf.SmtpAddress);

       AvailabilityOptions options = new AvailabilityOptions();
       options.MaximumSuggestionsPerDay = 48;
       // service is ExchangeService object contains your authentication with exchange server
       GetUserAvailabilityResults results = service.GetUserAvailability(attend, new TimeWindow(DateTime.Now, DateTime.Now.AddDays(2)), AvailabilityData.FreeBusyAndSuggestions, options);

        foreach (AttendeeAvailability attendeeAvailability in results.AttendeesAvailability)
                {
                    Console.WriteLine();
                    Console.WriteLine();
                    if (attendeeAvailability.ErrorCode == ServiceError.NoError)
                    {
                        foreach (Microsoft.Exchange.WebServices.Data.CalendarEvent calendarEvent in
                        attendeeAvailability.CalendarEvents)
                        {
                            Console.WriteLine("Calendar event");
                            Console.WriteLine(" Starttime: " + calendarEvent.StartTime.ToString());
                            Console.WriteLine(" Endtime: " + calendarEvent.EndTime.ToString());
                            if (calendarEvent.Details != null)
                            {
                                Console.WriteLine(" Subject:" + calendarEvent.Details.Subject);

                            }
                        }
                    }
                }
            }

关于问题 #3,获取此信息并不简单,因为它是私人信息,作为普通用户,您无权查看它。