Module Connecting Access to Outlook Public folder

Tiffosi2006

Registered User.
Local time
Today, 13:55
Joined
Nov 7, 2006
Messages
15
Hi,

I have been searching the forum all day and cant find anything on this (all relate to linking tables or private contacts)

I have an access database that i want to link up to an outlook public folder. The public folder is located in: Public folders/all public folders/your department/your section (and then there is a contacts folder held here called contacts )

I have the following code which will connect to my personal contacts but i cant work out how to connect to the above!! Help is VERY much appreciated!

Function ImportContactsFromOutlook()

' Set up DAO objects (uses existing "tblOutlook" table)
' Set a reference to the Microsoft Outlook 10.0 Object Library and the Microsoft DAO 3.6 Object Library.

Dim rst As DAO.Recordset
Dim NumRec As Long

Set rst = CurrentDb.OpenRecordset("tblContacts")

' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)

Thanks in advance,

Kev
 
Fix

Ok, figured it out.

When connecting to the folder you need to state each of your public folders by name as follows:

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olPublicFolderContacts).Folders("Your Department").Folders("Your Folder")

Hope this cuts out lots of time for others!!
 

Users who are viewing this thread

Back
Top Bottom