Edit

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.

Component Description Example
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. 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. 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 email 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. 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. This code shows the active Outlook window in Outlook: Application.ActiveExplorer.Display
NavigationPane Represents the Navigation Pane displayed by the active Explorer object.
Items collection 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 don't need to enter the object model to reference it. 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. 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'll add to the control toolbox before using them for the first time in a form.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.