Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Master Category List in Outlook 2002

6 views
Skip to first unread message

Andrew Cushen

unread,
May 24, 2003, 12:23:33 AM5/24/03
to
How can I access the Master Category List in Outlook 2002,
using Visual Basic 6.0?

I have been able to programmatically retrieve the MCL in
Outlook 97/98 and 2000 using a Class I found on the Net
that wraps the Registry API functions:

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnovba01/html/RegistryMadeEasy.asp

But when I try with Outlook 2002, I get an (unsupported
data format) message.
It seems the MCL is in Binary (D_WORD?) format. I have
tried various VB functions like AscB, CStr, Chr, etc., in
various combinations, to convert it to something usable in
VB, with no luck.

Any ideas would be very welcome.

The documentation for the class, available at the above
URL, states that it returns a Variant. However, I have had
success with Outlook 97/98 and 2000, just assigning the
return value to a String. This clearly won't work with
Outlook 2002.

Also, Does anyone know where & how the MCL will be stored
in Outlook 2003?

Thanks a lot,


-Andrew

Ken Slovak - [MVP - Outlook]

unread,
May 27, 2003, 9:40:44 AM5/27/03
to
The master category list in Outlook 2002 (and 2003) is in binary, with
the text represented as Unicode. For most Western languages that would
mean that every other character is a 0x00 and the next one is the
ASCII representation of the character.

To read the list is easy, take a look at the code sample using WSH for
reading a user's master
category list from the registry at
http://www.cdolive.com/cdo5.htm#ReadMasterCategories, it shows how to
do it for all versions of Outlook.

To write to the registry for the master category list you'd want to
use the Win32 API functions since the WSH RegWrite function can write
binary values to the registry, but
it can only write a DWORD's worth (4 bytes). Not very useful for
categories.

What you would have to do is use the Win32 API RegSetValueEx registry
function for that, with a type of REG_BINARY (3). You would get the
string you want to write to the master categories list and break it
apart character by character. After each character you would add a
CHR(0) value.

For a list of categories the easiest way would probably be to break
apart the list using the Split function to get each entry into an
array element. The Split character would be a comma. Then you would
construct a string to write to MasterList, including the commas after
each category from each element of the array.

Here's a very simple example that writes the string "Foo" as a new
master category list entry. Just remember that MasterList won't exist
unless you have previously added a new category to the master list, or
you create the key using the Win32 API functions to create it.

Const REG_BINARY = 3
Const HKEY_CURRENT_USER = &H80000001
Const ERROR_NONE = 0
Const KEY_ALL_ACCESS = &H3F

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
Alias "RegOpenKeyExA" _
(ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal ulOptions As Long, _
ByVal samDesired As Long, _
phkResult As Long) As Long

Private Declare Function RegSetValueEx Lib "advapi32.dll" _
Alias "RegSetValueExA" _
(ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
lpData As Any, _
ByVal cbData As Long) As Long

Sub WriteNewCategory()
Dim hKey As Long
Dim lRetVal As Long
Dim sCategory As String
Dim lLen As Long
Dim sKeyName As String

sKeyName = "Software\Microsoft\Office\10.0\Outlook\Categories"

sCategory = "F" & Chr(0) & "o" & Chr(0) & "o" & Chr(0)
lLen = Len(sCategory)

lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0&, _
KEY_ALL_ACCESS, hKey)

If lRetVal = ERROR_NONE Then
lRetVal = RegSetValueEx(hKey, "MasterList", 0&, REG_BINARY, _
ByVal sCategory, lLen)
End If
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


"Andrew Cushen" <and...@REMOVETOREPLYcushen.com> wrote in message
news:14cd01c321ac$3d13b8a0$a301...@phx.gbl...

Andrew Cushen

unread,
May 31, 2003, 6:10:43 PM5/31/03
to
Thanks alot Ken.

I found a VB function that will read binary values from
the Registry at:
http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=238

There is a link at the bottom of the page to a function
that will write binary values.

I did in fact find the WSH code you mention at
cdolive.com, but had some trouble translating it to VB.
Dropping the function I mentioned into my VB project as a
Module did the trick.

So you are saying that, just like reading the MCL, there
is no way to create a new Category programmatically, other
than adding it to the end of the Registry value? This
seems rather short-sighted by the Outlook VBA team.. .

Thanks again.

-Andrew

>.
>

Sue Mosher [MVP]

unread,
Jun 5, 2003, 8:46:55 PM6/5/03
to
PMJI, but what's short-sighted about it? All the master category list does is give users a convenient list to pick from. There is no correlation between the MCL and the category data stored in the actual items. They don't have to match at all. You "create" a category in effect by setting that category on one or more items.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.slipstick.com/books/jumpstart.htm

"Andrew Cushen" <and...@NOSPAMcushen.com> wrote in message news:059201c327c1$7a58d7c0$a001...@phx.gbl...

0 new messages