How to get Categories list?

  • Thread starter Thread starter michaaal
  • Start date Start date
M

michaaal

How can I get my categories list? (the categories that I put my Contacts in)

Is this even close...?

Dim objApp As Application
Dim objNS As NameSpace
Dim objContacts As MAPIFolder
Dim objItem As Object

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
x = set objContacts.Categories
For Each objCategories in x
msgbox(objCategories)
Next
 
michaaal said:
How can I get my categories list? (the categories that I put my Contacts in)

Is this even close...?

Dim objApp As Application
Dim objNS As NameSpace
Dim objContacts As MAPIFolder
Dim objItem As Object

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
x = set objContacts.Categories
For Each objCategories in x
msgbox(objCategories)
Next


Ok...so I found the categories list here in the registry...
HKCU\Software\Micdrosoft\Office\9.0\Outlook\Categories

But how to you tell if a contact belongs to a particular category???
 
You have to read the Categories property for each contact or you can search
in the Items collection of the folder for a specific category, but you can't
use Outlook's Find or Restrict for that. They don't allow searching on
Categories. You could use a MAPITable restriction to do it but that would
require Extended MAPI (C++ or Delphi code only) or Redemption code
(www.dimastr.com/redemption).
 
You need to check the ContactItem.Categories property of each contact. It's
a keywords
field so you can break it into an array with Split() to match against some
other list that you want to check. Remember that a contact may have
categories that are not in the master list.
 
I've used Find and Restrict with Categories OK in the past. It's certainly
worth trying.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Another thing we need to tell MS the help isn't right about then? In the
Object Browser Help on Restrict it lists Categories as a prop that can't be
used...
 
Back
Top