Searching Contacts on a UserProperty

  • Thread starter Thread starter McKilty
  • Start date Start date
M

McKilty

I'm trying to update a routine that will update out Outlook Recipients
lists with an employee database. I've added a custom field to the
contacts called EMPID. What I would like to do is search the contacts
for a specific Employee ID (EMPID) and then update it with the
information from the database.

I'm unable to search on this field apparently:


Error: -659423223
The property "EMPID" is unknown.


Dim myFolder As Outlook.MAPIFolder
Dim myNameSpace As Outlook.NameSpace
Dim myOutlook As Outlook.Application
Dim myPublicContact As Outlook.ContactItem

Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(Outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders("Recipients List")
Set myPublicContact = myFolder.Items.Find("[EMPID] = ""472""")
 
Ok, I finally found the answer. I had been searching for awhile
before posting, then I posted and continued to search, and found the
answer.

I had to create the UserProperty for the folder, not on a specific
item. I did this and went to a user and the property wasn't there.
It was in the folder view that I had, so I just went down the list and
added the value and then it was searchable. Pretty odd...

Anything else I should know about this?
 
You can also use the SQL syntax when calling Find and specify the property
name in the DASL format

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Back
Top