ContactCollection.Find - searching via multiple properties

F

farseer

Hi,
Is there a way to search the ContactCollection by say FirstName,
LastName and PhoneNumber? it seems the Find method takes a
PropertyDescriptor which means you can only search via one property it
seems...unless i am missing something.

OutlookSession ol = new OutlookSession();
ContactCollection col = ol.Contacts.Items;
PropertyDescriptor prop =
TypeDescriptor.GetProperties(GetType(Contact)).Item("LastName");
int id = col.Find(prop, "Smith");

What happens if you have 5 "Smiths" in your contact? How can i specify
a more refined search here by searching by more than one property.
 
F

farseer

had a brilliant idea to use the Restrict method, but getting an
exception with the following code

col = col.Restrict( "[FirstName]='John' AND [LastName]='Smith'" );

error: "The query string is incorrectly formatted."
 
F

farseer

solved: with the restrict, need to use use double quotes (asci
34?)..so should look like:

col = col.Restrict( "[FirstName]=\"John\" AND [LastName]=\"Smith\"" );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top