2

With this code I get the extended properties for contacts with a specific display name:

foreach(Contact c in contacts)
{
  // some code...
  view.PropertySet = new PropertySet(BasePropertySet.IdOnly, properties);
  filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, c.DisplayName);
  items = service.FindItems(folderId, filter, view);
}

I want to filter not by the DisplayName but by the Contact.Id, but i can't find a way to do that.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Thiago
  • 1,103
  • 1
  • 16
  • 25

2 Answers2

0

To search by Contact.Id use the ItemSchema.Id like given below...

filter = new SearchFilter.IsEqualTo(ItemSchema.Id, c.Id);
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
  • I tried, but it throws an ArgumentException with the message "Validation failed. Parameter name: searchFilter" – Thiago May 16 '12 at 18:18
0

That's what I have done in the end, i did not find a better solution. I get all contacts with the same name and iterate through them to find the correct contact.

        foreach (Item item in items.Items)
        {
            foreach (var ext in item.ExtendedProperties)
            {
                // check if the extended property is from this contact
                if (c.Id.ChangeKey == item.Id.ChangeKey)
                {
                    extendedProperties.Add(ext);
                }
            }
        }
Thiago
  • 1,103
  • 1
  • 16
  • 25