Populate combobox with public folder contact

S

Sue Mosher [MVP-Outlook]

To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164

After you have the folder, the technique is the same as in the article you cited.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks alot for your answer! All works fine! The only thing I can't manage to
do now is to get the names from the GAL.

My Contacts folder works fine with:
Set objSession = Application.GetNameSpace("MAPI")
Set objContactFolder = objSession.GetDefaultFolder(10)
Set objAllContacts = objContactFolder.Items

My public contacts folder works fine with:
Set objSession = Application.GetNameSpace("MAPI")
Set objContactFolder = GetPublicFolder("External contacts")
Set objAllContacts = objContactFolder.Items

But when I try this for the GAL...
Set objSession = Application.GetNameSpace("MAPI")
Const CdoAddressListGAL = 0
Set objAddressList = objSession.GetAddressList(CdoAddressListGAL)
Set objAddressEntries = objAddressList.AddressEntries

.... it fails with the erromessage:
Object doesn't support this property or method: 'objSession.GetAddressList'

Why oh why?
 
S

Sue Mosher [MVP-Outlook]

Looks like you're confusing the Session objects in CDO 1.21 and Outlook. In Outlook, you must get the address list from the Namespace.AddressLists collection.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

I hoped I wouldn't need CDO since I don't know what it is. But after some
researching/parrot-coding i found the solution, by changing the first two
lines to this:

Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False, 0

The only problem now is that is asks for permission to read the address book
but I will try to solve that with Outlook Redemption.

Thanks!

"Sue Mosher [MVP-Outlook]" skrev:
 

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