Searching by User Property


S

Sick Boy

Hello.

My toolbar marks Outlook objects (Contacts and Appointments) by
setting my custom property
UserProperties("id") as number. I need to find Contacts by this id
property's value.

I've got 2 examples of my code:

1)
strFilter = "[MessageClass] > 'IPM.Contacs' And [MessageClass] <
'IPM.Contacu' And [id] > '0'"
If FindFolder.Items.Count > 0 Then
Set colObj = FindFolder.Items.Restrict(strFilter)
For i = 1 To colObj.Count
...
Next i
End If


2)
Set colContTest = FindFolder.Items.Restrict("[FirstName] = 'Fulvio'
And [LastName] = 'Grignani'")
If colContTest.Count > 0 Then
Set oContTest = colContTest.GetFirst
id_t = oContTest.UserProperties("id")
cid_t = oContTest.UserProperties("cid")
End If
Set colContTest = FindFolder.Items.Restrict("[id] = '" & id_t &
"'")

The first part of code is used to delete all objects which have IDs.
It works OK.

The second part of code is taken from the procedure which is used to
find contact by id. It doesn't work correctly. It finds contact by
name and after that gets it's id and cid correctly. But it can't find
the same contatct by it's "id" property. The colContTest collection
have 1 object after executing the first string, but is empty after the
last string.
I don't understand why almost the same functionality works in one
procedure, but doesn't work in nother one.
 
Ad

Advertisements

G

Guest

If those custom fields don't also exist in the folder then the Restrict
method should generate an error. Can you see them listed in the User Defined
Fields in Folder section of the Field Chooser?
 

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