Export (0) Print
Expand All
4 out of 7 rated this helpful - Rate this topic

Starting an Outlook Automation Session

Office 2007

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;
    
    [VBA]
    Dim objOL as Outlook.Application
    Set olApp = CreateObject("Outlook.Application")
    
  2. Set a Namespace object to refer to MAPI folder.
    [C#]
    Outlook.NameSpace olNameSpace = _app.GetNamespace("MAPI");
    
    [VBA]
    Dim objNS As Outlook.NameSpace
    Set objNS = olApp.GetNamespace("MAPI")
  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"]; 
    
    [VBA]
    Dim olFolders As Outlook.Folders
    Dim bcmRootFolder As Outlook.Folder
    
    Set olFolders = objNS.Session.Folders
    Set bcmRootFolder = olFolders("Business Contact Manager") 
    

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 | Office Developer Center: Outlook 2007



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.