Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Outlook contacts with MS Access

E-mail Attached Files

Create Outlook contacts with MS Access

by  adstam  Posted    (Edited  )
[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

End Function

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top