Outlook Folder Object Types

D

Dave

Looking at the example below, how would I put some code in here to know that
a folder is specifically a folder containing outlook contacts ?

Dim ofldrs As Outlook.Folders
Dim ffldrs As Outlook.MAPIFolder
Set ofldrs = g_fldr.Folders
Set ffldrs = ofldrs.GetFirst()
Do While Not ffldrs Is Nothing
' put something here to check the type -
Set ffldrs = ofldrs.GetNext()
Loop

I know to look at the Class and it will tell me the object is a folder
(olFolder) or at the Class and know it is a contact (olContact) but how do
I know a folder is a Contact Folder, like Outlook 2003 does ?
 
K

Ken Slovak - [MVP - Outlook]

Look at DefaultItemType, it will be olContactItem for a contacts folder.
Outlook 2003 also has a DefaultMessageClass property, a substring search on
that would look for "IPM.Contact" for a contacts folder. But DefaultItemType
will work will all Outlook versions.
 
D

Dave

How do I get the Personal Folders root folder object ? Outlook 2003 because
of how it is setup, users are now creating contact folders all over the
place, which is requiring me to look for the contact folders where ever they
might be. The problem is I don't know how to retrieve the root folder
object to start searching through.

What a mess :(
 
K

Ken Slovak - [MVP - Outlook]

You can't get at the RootFolder (in MAPI terms) using the Outlook object
model. You can get to Top of Information Store, which is what I think you
meant (the Outlook Today folder). NameSpace.Folders gives you the Top of
Store for each store opened by the user. For an easy way to get there for
the default store:

Set oFolder = oNS.GetDefaultFolder(olFolderInbox).Parent

That's the Top of Store folder and if you get that folder's Folders
collection you can iterate it to check for any Contacts folders.
 
D

Dave

Wouldn't this give me the top too ?

Set ofldrs = g_ns.Folders("Personal Folders").Folders

or is your way better ?
 
K

Ken Slovak - [MVP - Outlook]

It would if it was always called "Personal Folders". You can't always rely
on that. The way I mentioned will always work, even in non-English language
installations.
 
D

Dave

Thanks, I will take your approach


Ken Slovak - said:
It would if it was always called "Personal Folders". You can't always rely
on that. The way I mentioned will always work, even in non-English language
installations.
 

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