This applies equally to WindowsMobile In The Hand and the Windows Mobile 5.0 APIs. On the collection classes there exists a Restrict method which returns a subset of the collection matching your search query. You can use the resulting collection to databind or otherwise enumerate over.
The query language used is similar, but not the same, as SQL: if you imagine that what you are entering here is just the WHERE clause of a query you will not be far off. The key rules to follow are:-
You can return a full contact list for all items with a mobile number using this code:-
os = new OutlookSession();PimItemCollection pic = os.Contacts.Items.Restrict("[MobileTelephoneNumber] <> \"\"");listBox1.DataSource = pic;
listBox1.DisplayMember = "FileAs"
This example bind the collection to a control, the list will show the contact name only but you'll be able to retrieve the Contact object from the SelectedItem property of the list box to use it's other properties (e.g. the mobile number).
For Windows Mobile 5.0 you can use the new ChooseContactDialog which features a RequiredProperties property so you can easily setup the dialog to show only relevant items.
Update: Here is the VB equivalent:-
os = New OutlookSessionDim pic As PimItemCollection = os.Contacts.Items.Restrict("[MobileTelephoneNumber] <> " & Chr(34) & Chr(34))ListBox1.DataSource = picListBox1.DisplayMember = "FileAs"
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.