Automating Outlook Contacts from Access

L

Leyland

Hi,
Are there any developers out there which know how to
programatically create contacts in Outlook from Access.
I can create new contacts in the Contacts Default folder,
however I don't know how to move them into sub folders or
create them in different folders.

i.e This code creates a contact but how do I then move
the contact to a different folder

'Create a Microsoft Outlook object.
Set objOutlook = CreateObject("Outlook.Application")

Set olns = objOutlook.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
'Create and open a new contact form for input.
Set objItem = objOutlook.CreateItem(olContactItem)

With objItem

.MessageClass = "IPM.Contacts
.FullName = "Leyland"
.Phone = "9999 9999"

.Save
'.Close


End With

'Quit Microsoft Outlook.
Set objOutlook = Nothing

Some help would be much appreciated.

Leyland
 
S

Sue Mosher [MVP]

If you want to store an item in a non-default folder, create it in that
folder with the MAPIFolder.Items.Add method instead of
Application.CreateObject. 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.slipstick.com/dev/code/getfolder.htm

FYI, there is a newsgroup specifically for general Outlook programming
issues "down the hall" at microsoft.public.outlook.program_vba
 

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