计算已接受与EWS会面的与会者人数

时间:2014-01-15 08:45:37

标签: c# exchange-server exchangewebservices

我正在努力计算与会者的数量,他们接受了会议邀请,参加EWS会议。

我能够通过模仿看到组织者会议,并计算会议所需的与会者人数。

        //Determine User to impersonat
        string impersonated_email = "user@domain";
        service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, impersonated_email);

        //Bind User Calendar
        FolderId UserCalendarId = new FolderId(WellKnownFolderName.Calendar, impersonated_email);
        CalendarFolder UserCalendar = CalendarFolder.Bind(service, UserCalendarId);

        // Initialize values for the start and end times, and the number of appointments to retrieve.
        DateTime startDate = DateTime.Now.AddDays(0);
        DateTime endDate = startDate.AddDays(1);

        // Execute the search in the calendar folder and return the view
        CalendarView userCalendar = new CalendarView(startDate, endDate);
        userCalendar.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
        FindItemsResults<Appointment> apt = service.FindAppointments(WellKnownFolderName.Calendar, userCalendar);

        foreach (Item item in apt.Items)
        {
            //Console.WriteLine(item.Subject);
            ServiceResponseCollection<GetItemResponse> myColl = service.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, userCalendar.PropertySet);
            foreach (GetItemResponse temp in myColl)
            {
                Appointment app = (Appointment)temp.Item;
                Int32 Tn = app.RequiredAttendees.Count-1;
                Console.WriteLine(app.Subject + " " +Tn);
            }

我还想看看有多少参与者已经接受了会议邀请。

亲切的问候 Xristos

1 个答案:

答案 0 :(得分:2)

您应该能够获得如下响应类型:

Appointment app;

int count = app.RequiredAttendees.Count(x => (x.ResponseType.HasValue && x.ResponseType.Value == MeetingResponseType.Accept));