Share via


About the Object Environment

There are two ways to write code for Microsoft Outlook:

  • From outside the application, such as by using Microsoft Visual Basic or Microsoft Visual Basic for Applications in Microsoft Excel or another application.

  • From inside the application, such as by using Visual Basic for Applications or by using VBScript with an Outlook form.

Major components of the Outlook object model

The following table shows the major objects in the Outlook object model.

Application

The top of the object hierarchy that represents the entire application. Enables you to reference other objects in the application and create items and objects. For example, this code creates an appointment in Outlook:

Application.CreateItem(1).Display

NameSpace

Represents the MAPI message store where all the Outlook items are stored. Provides methods for logging on and off Outlook and for referencing the default folders such as Mailbox, Inbox, Contacts, and others. For example, this code references the active user in Outlook:

Application.GetNameSpace("MAPI").CurrentUser

Account

Represents an account defined for the current profile.

Store

Represents a file on the local computer or a network drive that stores e-mail messages and other items for an account in the current profile.

Folders

There are two folder objects, the Folders collection object that enables you to work with collections of folders and the Folder object that enables you to work with a single folder. For example, this code shows the collection of folders named Personal Folders in Outlook:

Application.GetNameSpace("MAPI").Folders("Personal Folders")

Table

Represents a set of item data from a Folder or Search object, with items as rows of the table and properties as columns of the table.

Rule

Represents an Outlook rule.

View

Represents a customizable view used to sort, group, and view data.

Explorer

Represents the Outlook window. Enables you to show, return, and close the active window. For example, this code shows the active Outlook window in Outlook:

Application.ActiveExplorer.Display

NavigationPane

Represents the Navigation Pane displayed by the active Explorer object.

Outlook items

There are two item objects, the Items collection that enables you to work with items within a folder and the item objects that represents the standard item types in Outlook, such as MailItem that represents a mail message. In VBScript, the active item is assumed, so you do not need to enter the object model to reference it. For example, this code sets the Subject field of the active message in VBScript:

Item.Subject = "New Subject"

Inspector

References forms. Use to show forms and pages. For example, this code shows the Options page of a form in Outlook:

Application.ActiveInspector.SetCurrentFormPage("Options")

FormRegion

Represents a form region in an Outlook form.

Attachment

Represents a document or link to a document contained in an Outlook item.

PropertyAccessor

Provides the ability to create, get, set, and delete properties on objects.

ItemProperty

Represents information about a given item property for an Outlook item object.

UserProperty

Represents a custom property of an Outlook item.

AddressEntry

Each AddressEntry object in the AddressEntries collection holds information that represents a person or process to which the messaging system can deliver messages.

AddressList

The AddressList object is an address book that contains a set of AddressEntry objects. The entire hierarchy is available through the parent AddressLists collection.

ExchangeUser

Provides detailed information about an AddressEntry that represents a Microsoft Exchange Server mailbox user.

ExchangeDistributionList

Provides detailed information about an AddressEntry that represents an Exchange distribution list.

Recipient

Represents a user or resource in Outlook, generally a mail message addressee.

Exception

The Exception object holds information about one instance of an AppointmentItem object which is an exception to a recurring series. Unlike most of the other Outlook objects, the Exception object is a read-only object.

Control

There are the Microsoft Forms 2.0 controls that exist in the control toolbox by default, and the Outlook controls that are installed on your computer by default and that you will add to the control toolbox before using them for the first time in a form.