Skip to content

Exporting Access Contacts to a Outlook Public Folder

How to export contacts from an Access table to an Outlook folder.

Q:  Farouk Dawood has written code to export contacts from an Access table to an Outlook folder, using the CreateItem(olContactItem) syntax, but it isn’t working – the new contacts are being created in the default local Contacts folder instead.  What is the syntax for creating contacts in a public folder?

A:  If you use CreateItem for creating a new Outlook item, the new item is created in the default local folder.  To create the contacts in a custom folder, use the Add method of that folder’s Items collection instead.  Also, since your folder variable is set to the top-level All Public Folders folder, you need to add the actual folder name to it:

Set fldContacts = olns.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders(“Clients contact list”)

 

Then use

Set itm = fldContacts.Items.Add(“IPM.Contact”)

 

to add a standard contact item.  Your code creates custom properties for the new contact item, but you can also create new contact items using a custom contact form, with the custom properties set up in advance — see my Code Sample #49, on the Code Samples page of my Web site, for more details on this technique.

About this author