INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

E-mail Attached Files

Create Outlook contacts with MS Access by adstam
Posted: 14 Mar 01

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)


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")

'to point to a nested folder in Outlook you have to create folder items in folder items:
Set MyContacts = Nms.Folders.Item("Public Folders").Folders.Item("Our Contacts")
Set MyItems = MyContacts.items

While Not Rst.EOF
æDeclare which form to be used to add your contacts
    Set MyItem = MyItems.Add(ôIPM.Contact.MyContactFormö)

æ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!
    MyItem.Title = Rst!Title
    MyItem.FirstName = Rst!Firstname
'MyItem.Etc = Rst!Etc
    MyItem.close (olSave)
    Rst.MoveNext

End Function


Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close