Search code examples
ms-accessvbaoutlookobject-model

Create an external table in access with outlook contacts programmatically


I'm not sure if this is possible, but i would like to create an external table in access with outlook contacts programmatically. I've searched in the Microsoft Access object model, but couldn't find a method or property that enables you to do so.

I need this for synchronizing contact persons between outlook and an application I'm building. I know there are other ways, but this option seems to be the simplest one.


Solution

  • Below is an example how to do this in visual basic.

    Set td = New TableDef
    td.Connect = "Outlook 9.0;MAPILEVEL=Postbus - Hello World|;" & _ 
                    "PROFILE=Microsoft Outlook Internet Settings;" & _ 
                    "TABLETYPE=0;TABLENAME=Contactpersonen;" & _ 
                    "DATABASE=C:\DOCUME~1\********\LOCALS~1\Temp\"
    td.SourceTableName = "Contactpersonen"
    td.Name = "TestContactpersonen"
    db.TableDefs.Append td