Starting an Outlook Automation Session

Because Microsoft Outlook supports automation, you can control Outlook from any program written with Microsoft Visual Basic for Applications (VBA), Microsoft Visual Basic.NET, or Microsoft C#. Automation provides a standard method for one application to access the objects, methods, properties, and events of other applications that support automation.

The Outlook object model provides all of the functionality necessary to manipulate data stored in Outlook folders. Outlook stores all of its information in Messaging Application Programming Interface (MAPI) folders. You obtain Business Contact Manager for Outlook objects by instantiating Outlook objects.

To start an Outlook automation session, do the following:

  1. Instantiate an Outlook Application object, which is the highest-level object in the Outlook object model. All automation code must first define an Outlook Application object to be able to access any other Outlook objects.
    [C#]
    Outlook.ApplicationClass _app = new Outlook.ApplicationClass();
    Outlook.Application olApp = (Outlook.Application) _app;
    
    
    FakePre-241385096a5244209db2d4c89017299e-f8003a46fd26492fa67cd51ddd193f31
  2. Set a Namespace object to refer to MAPI folder.
    [C#]
    Outlook.NameSpace olNameSpace = _app.GetNamespace("MAPI");
    
    
    FakePre-0b5581eb8b6645569d25b041175c28f3-59ee3ed808104fe8ae208cb2867c4bda
  3. Set an object variable to reference the folder that contains the items you will use.
    [C#]
    Outlook.Folders folders = olNameSpace.Session.Folders;
    Outlook.Folder bcmRootFolder = (Outlook.Folder)folders["Business Contact Manager"];
    
    
    FakePre-a1635488f5a14836b52efe5911d61ecb-2d68585a612445d58d5714ee42fbfbe0

The preceding code examples combine to form the correct reference to the Business Contact Manager root folder. You can then navigate to the following sub-folders objects:

See Also

Welcome to the Business Contact Manager for Outlook Developer Guide | Automating Business Contact Manager From a .NET Framework Application | Automating Business Contact Manager From a VBA Application | 2007 Office System: Updated Developer Content