looking for help with PIMItemCollection Find method

L

lansalot

Hi

I'm struggling with searching the Contacts on my PocketPC with
VS2005/.NET cf2 and hope someone can help please.

Specifically, the documentation for the Find method is a bit lacking
(to my eyes). You can see it here:

http://msdn.microsoft.com/library/d...Outlook_PimItemCollection_Find_1_917213a7.asp

I have no idea what I should be passing in as some sort of valid
PropertyDescriptor, nor the Key for that matter.

Can someone please help with a little example, say the simplest "find
contact for surname = 'smith'" sort of thing?

My nearest try was:

Dim o As New OutlookSession
criteria = "[LastName] = " & ControlChars.Quote & "Smith" &
ControlChars.Quote
MsgBox(o.Contacts.Items.Find(c.Properties("LastName"), criteria))

But obviously that's nowhere near right.

Also tried MsgBox(o.Contacts.Items.Find(c.Properties("LastName"),
"Smith"))

Nothing found. And it's there alright. I've seen how to use the
Restrict method, but that's not really the appropriate one to be using
so I guess I should learn to do it properly.

Thanks in advance for any help.
 
I

Ilya Tumanov [MS]

Right, that is not obvious. IBindingList is not exactly designed to be used
by humans directly.

Here's some sample (it's in C# but should not be too hard to convert to VB):

OutlookSession os = new OutlookSession();


ContactCollection cc = os.Contacts.Items;


Contact c;


c = new Contact();

c.FirstName = "John";

c.LastName = "Doe";

cc.Add(c);

c = new Contact();

c.FirstName = "Jane";

c.LastName = "Smith";


cc.Add(c);

PropertyDescriptor pdContact =
TypeDescriptor.GetProperties(typeof(Contact))["LastName"];

// Should be something like this in VB:

// Dim pdContact as PropertyDescriptor =
TypeDescriptor.GetProperties(GetType(Contact)).Item("LastName");

int smithIndex = cc.Find(pdContact, "Smith");


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
L

lansalot

Many thanks for that Ilya.

Looking at your solution, I doubt I would have been able to work that
out just by staring at the documentation.

Many thanks for your help :)
Right, that is not obvious. IBindingList is not exactly designed to be used
by humans directly.

Here's some sample (it's in C# but should not be too hard to convert to VB):

OutlookSession os = new OutlookSession();


ContactCollection cc = os.Contacts.Items;


Contact c;


c = new Contact();

c.FirstName = "John";

c.LastName = "Doe";

cc.Add(c);

c = new Contact();

c.FirstName = "Jane";

c.LastName = "Smith";


cc.Add(c);

PropertyDescriptor pdContact =
TypeDescriptor.GetProperties(typeof(Contact))["LastName"];

// Should be something like this in VB:

// Dim pdContact as PropertyDescriptor =
TypeDescriptor.GetProperties(GetType(Contact)).Item("LastName");

int smithIndex = cc.Find(pdContact, "Smith");


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

Hi

I'm struggling with searching the Contacts on my PocketPC with
VS2005/.NET cf2 and hope someone can help please.

Specifically, the documentation for the Find method is a bit lacking
(to my eyes). You can see it here:

http://msdn.microsoft.com/library/d...Outlook_PimItemCollection_Find_1_917213a7.asp

I have no idea what I should be passing in as some sort of valid
PropertyDescriptor, nor the Key for that matter.

Can someone please help with a little example, say the simplest "find
contact for surname = 'smith'" sort of thing?

My nearest try was:

Dim o As New OutlookSession
criteria = "[LastName] = " & ControlChars.Quote & "Smith" &
ControlChars.Quote
MsgBox(o.Contacts.Items.Find(c.Properties("LastName"), criteria))

But obviously that's nowhere near right.

Also tried MsgBox(o.Contacts.Items.Find(c.Properties("LastName"),
"Smith"))

Nothing found. And it's there alright. I've seen how to use the
Restrict method, but that's not really the appropriate one to be using
so I guess I should learn to do it properly.

Thanks in advance for any help.
 
Joined
Sep 11, 2006
Messages
1
Reaction score
0
Pocket Outlook FIND method

Hello (e-mail address removed),

It sounds like you got this to work...
Can you share the functional syntax in VB?
I am trying to look up based on the ItemID to go directly to pocket outlook tasks.

Thanks!
-Mark
 

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