[color green]Looking for a way to create/update contacts from an Access table to Outlook / Exchange it was hard to find a complete answer.
The first thing I tried was to make a connection with the Exchange connector from Access 2000. Problem in that solution is that there is a subset of the fields available, bigger problem was that created contacts where made in an e-mail form. Therefore I had to write VBA module.
In various KB's and forum I found parts of the solution. I try to describe it as complete as possible.
Don't forget that to use the outlook classes you have to add the Microsoft Outlook 9.0 Object Library to your application (extra / references) [/color]
Function AddContacts
Dim OutlookObj as Outlook.Application
Dim Nms as Outlook.namespace
Dim MyContacts as Object
Dim MyItems as Object
Dim MyItem as Object
Dim Db as Database
Dim Rst as Recordset
Set DB = CurrentDb
Set Rst = db.openrecordset("q_mycontacts", dbopendynaset)
Set OutlookObj = CreateObject("Outlook.application")
Set Nms = OutlookObj.GetNameSpace("MAPI")
[color green] 'to point to a nested folder in Outlook you have to create folder items in folder items: [/color]
Set MyContacts = Nms.Folders.Item("Public Folders").Folders.Item("Our Contacts")
Set MyItems = MyContacts.items
While Not Rst.EOF
[color green]æDeclare which form to be used to add your contacts [/color]
Set MyItem = MyItems.Add(ôIPM.Contact.MyContactFormö)
[color green]æadd fields, to find out which fields are available take a look at all the available members of the ContactItem class in the Outlook object library. Be careful, Microsoft is using various names for outlook fields! [/color]
MyItem.Title = Rst!Title
MyItem.FirstName = Rst!Firstname
[color green]'MyItem.Etc = Rst!Etc[/color]
MyItem.close (olSave)
Rst.MoveNext
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.