
Accessing Objects in an Outlook Project
Outlook provides many classes with which you can interact. To use the object model effectively, you should be familiar with the following top-level classes:
Application Class
The Application class represents the Outlook application, and it is the highest-level class in the Outlook object model. Some of the most important members of this class include:
The CreateItem method which you can use to create a new item such as an e-mail message, task, or appointment.
The Explorers property, which you can use to access the windows that display the contents of a folder in the Outlook user interface (UI).
The Inspectors property, which you can use to access the windows that display the contents of a single item, such as an e-mail message or meeting request.
To get an instance of the Application class, use the Application property of the ThisAddin class.
ThisAddIn Class
When you create a new Outlook add-in project, Visual Studio Tools for Office automatically creates a ThisAddIn.vb or ThisAddIn.cs code file in your new project. This code file defines a ThisAddin class that inherits from OutlookAddIn. You can access the members of the OutlookAddIn class by using the keywords Me (in Visual Basic) or this (in C#) within the ThisAddIn class. Code that is outside the ThisAddIn class can access the ThisAddIn object by using the static Globals.ThisAddIn property.
Explorer Class
The Explorer class represents a window that displays the contents of a folder that contains items such as e-mail messages, tasks, or appointments. The Explorer class includes methods and properties that you can use to modify the window, and events that are raised when the window changes.
To get an Explorer object, do one of the following:
Inspector Class
The Inspector class represents a window that displays a single item such as an e-mail message, task, or appointment. The Inspector class includes methods and properties that you can use to modify the window, and events that are raised when the window changes.
To get an Inspector object, do one of the following:
MAPIFolder Class
MailItem Class
The MailItem class represents an e-mail message. MailItem objects are usually in folders, such as Inbox, Sent Items, and Outbox. MailItem exposes properties and methods that can be used to create and send e-mail messages.
For an example that shows how to create an e-mail message, see How to: Create an E-Mail Item.
AppointmentItem Class
The AppointmentItem class represents a meeting, a one-time appointment, or a recurring appointment or meeting in the Calendar folder. The AppointmentItem class includes methods that perform actions such as responding to or forwarding meeting requests, and properties that specify meeting details such as the location and time.
For an example that shows how to create an appointment, see How to: Create a Meeting Request.
TaskItem Class
The TaskItem class represents a task to be performed within a specified time frame. TaskItem objects are located in the Tasks folder.
To create a task, use the CreateItem method of the Application class, and pass in the value olTaskItem for the parameter.
ContactItem Class