Search code examples
c#exchangewebservicesews-managed-api

Attendee.ResponseType Unknown - Exchange Managed API


I've got a problem when attempting to get the ResponseType of the room that is a required attendee for an appointment. I can confirm that my exchange 2010 sp2 ru4 server instantaneously approves or declines meetings but when I programically findappointment with the ExchangeManaged api the required attendee in question always returns an "Unknown" value for the ResponseType.

Here's my code...

 public bool IsAppointmentVerifiedWithResource(Patron userSessionObj, Reservation reservation)
    {
        var emailConfig = new DataStoreManager.ConfigurationManager();
        var serviceBinding = emailConfig.GetConfiguration(Configuration.GetConfigurationName(Resource_ConfigurationConstants.ExchangeServiceBinding));

        // Create the binding.
        var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
        {
            UseDefaultCredentials = true,
            Url = new Uri(serviceBinding)
        };

        // Set the calendar view to use
        var view = new CalendarView(reservation.Start, reservation.End);

        // Get the target folder ID using the email address
        var folder = new FolderId(WellKnownFolderName.Calendar, new Mailbox(reservation.EmailAddress));

        view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);

        if (CheckForApptCount(service, folder, view))
        {
            var response = service.FindAppointments(folder, view);

            service.LoadPropertiesForItems(from Item item in response select item, BasePropertySet.FirstClassProperties);

            foreach (Appointment apt in response.Items)
            {
                foreach(Attendee at in apt.RequiredAttendees)
                {
                    //room mailbox matches required attendee
                    if(at.Address == reservation.EmailAddress)
                    {
                        ******at.ResponseType always = Unknown******
                        if(at.ResponseType == MeetingResponseType.Accept)
                        {
                            return true;
                        }
                    }
                }
            }

        }

        return false;

    }

Any ideas on how to get the ResponseType property synchronized and loaded?

Thanks, Chris

*******************UPDATE - FINDING Organizer appointments*******************

    public List<Appointment> RetrieveExistingReservations(DateTime selectedDate)
            {
               var service = new ExchangeService()
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");                

 using (WindowsIdentity.Impersonate(service.ImpersonatedUserId))
                {
                    return EwsWrapper.GetStandardCalendarItems(service, selectedDate, selectedDate.AddDays(30));
                }
            }

            public static List<Appointment> GetStandardCalendarItems(ExchangeService service, DateTime dtStart, DateTime dtEnd)
            {
                // Instantiate a collection to hold occurrences and exception calendar items.
                List<Appointment> foundAppointments = new List<Appointment>();

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

                //// Create a calendar view to search the calendar folder and specify the properties to return.
                CalendarView calView = new CalendarView(startDate, endDate)
                {
                    PropertySet = new PropertySet(BasePropertySet.FirstClassProperties)
                };

                // Retrieve a collection of calendar items.
                FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView);

                // Add all calendar items in your view that are occurrences or exceptions to your collection.
                foreach (Appointment appt in findResults.Items)
                {


                    foundAppointments.Add(appt);

                }

                return foundAppointments;
            }

Solution

  • SOLUTION FOUND: The ResponseType of the attendee was always null because I was doing a "findappointments" for the attendee's mailbox and then attempting to get the ResponseType of this attendee. The correct way to get the ResponseType of an Attendee is to run "findappointments" for the organizer's mailbox. Once you find the appointment, enumerate the attendee's and the ResponseType will be available.