Reading meeting attendees using EWS Managed API always gives an empty collection
Hello

I left MS France 2 months ago and I'm already confronted to an issue using EWS Managed Api 1.0 that I fail to solve, so I come here to request some help...

Basically I need to read the attendees list of a meeting using RequiredAttendees / OptionalAttendees.
But though I can add without problem some attendees to an Appointment, I cannot read the ones set, I always get an empty collection.

I use a sample code that creates an appointment using EWS Managed API, adds some attendees (and I can see them from OWA), but just after reading again the appointment the attendees list is empty (i can share the code tomorrow if needed).
Did I miss something, or maybe isn't it the right way to read the list of attendees for an existing meeting using EWS managed API v1?

Many thanks by advance
Nico
March 9th, 2010 10:24pm

Never mind, I found the solution that was already a bit discussed in the following threads
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/ce1e0527-e2db-490d-817e-83f586fb1b44
http://social.technet.microsoft.com/Forums/en-GB/exchangesvrdevelopment/thread/87218f40-15c5-4560-b3e0-493bc817927b

FindItem() doesn't return either RequiredAttendees, OptionalAttendees and Resources as a search, closest are DisplayTo, DisplayCc fields.
To get those collections populated, you need to do an actual bind. I fixed my code by use bellow BindToItems(), maybe LoadPropertiesForItems() works too.

However I think that would be appreciated by the community to either have sample codes on how to read attendees for an existing meeting (all sample only show how to add attendees, that doesn't require such bind), or to have a kind of ServiceObjectPropertyException ("This property was requested but was not returned by the server") rather than an empty collection...

            // Execute the search in the calendar folder and return the view

            FindItemsResults<Item> iCol = service.FindItems(WellKnownFolderName.Calendar, sf, view);

            foreach (Item item in iCol.Items)

            {

                Console.WriteLine(item.Subject);

                ServiceResponseCollection<GetItemResponse> myColl = service.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, new PropertySet(BasePropertySet.FirstClassProperties));

                foreach (GetItemResponse temp in myColl)

                {

                    Appointment appTest = (Appointment) temp.Item;

                    Console.WriteLine(appTest.RequiredAttendees.Count);

                }

            }

 

Thx
Nico

  • Marked as answer by nicd_msft Wednesday, March 10, 2010 1:04 PM
Free Windows Admin Tool Kit Click here and download it now
March 10th, 2010 11:31am

You can (and should) optimize your code by binding to all the items returned by FindItems in one call to EWS:

// Execute the search in the calendar folder and return the view
FindItemsResults<Item> findResults = service.FindItems(
    WellKnownFolderName.Calendar,
    searchFilter,
    view);

// Load first class properties on all the items in findResults in one call to EWS
service.LoadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

Note the use of LoadPropertiesForItems as opposed to BindToItems. The latter is useful when you only have the Ids of the items you want to bind to; the former is better when you already have the actual items at hand, which is the case after a call to FindItems.

Also note that the above example is not perfect in the sense that if FindItems returns a large number of items you should call LoadPropertiesForItems for small batches of say 25 items at a time.

Also, to bind to a single item, using the static Item.Bind method (or Appointment.Bind if the item you are binding to is an appointment) is simpler than using ExchangeService.BindToItems.
March 11th, 2010 6:05pm

If you already have an appointment, all you need to do is to bind it to the service and get first class properties


 foreach (Appointment a in room.appointments)
 {

var app = Appointment.Bind(service, a.Id, new PropertySet(BasePropertySet.FirstClassProperties));

    Console.WriteLine(app.RequiredAttendees.Count);
        Console.WriteLine(app.OptionalAttendees.Count);
        Console.WriteLine(app.Resources.Count);

}

Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 7:36am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics