Outlook and VB.Net -Outlook Object model

This article shows what the outlook object model is and how to use with vb.net; article describes some approaches of outlook object modal.

Microsoft Office provides a powerful component model to automate from another program or application. We can read, delete and manage Mail Items, Calendar Items, Journal Entries, and any other item that Outlook normally exposes such as Contacts, Notes, Tasks using outlook Object modal. We   can automate Outlook from a .NET application with the help of COM Interop. First we will discuss about Outlook Object model .

The Outlook object model provides various objects such as Application ,Explorer,Inspector,MAPIFolder, MailItem,AppointmentItem ,TaskItem,ContactItem  etc

 Application Object (this is the main or root object):

Using the Application Object

When you use Automation to control Microsoft Outlook from another application, you use the CreateObject method to create an Outlook Application object.

The following Visual Basic for Application example starts Microsoft Outlook (if it's not already running) and opens the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")

Set myNameSpace = myOlApp.GetNameSpace("MAPI")

Set myFolder= myNameSpace.GetDefaultFolder(olFolderInbox)

myFolder.Display

              

Namespace object (responsible for controlling sessions, folders operation, items etc)

 Represents an abstract root object for any data source. The object itself provides methods for logging in and out, accessing storage objects directly by ID, accessing certain special default folders directly, and accessing data sources owned by other users.

Using the NameSpace Object

Use GetNameSpace ("MAPI") to return the Outlook NameSpace object from the Application object.

The only data source supported is MAPI, which allows access to all Outlook data stored in the user's mail stores.

 Explorer Object (responsible for showing all outlook folders)

Inspector Class (it is responsible for showing the item)

Use the Inspectors property to return the Inspectors object from the Application object. The following example shows how to retrieve the Inspectors object in Microsoft Visual Basic or Microsoft Visual Basic for Applications (VBA).

Dim myOlApp as New Outlook.Application

Set myInspectors = myOLApp.Inspectors

              

The following example shows how to retrieve the Inspectors object in Microsoft Visual Basic Scripting Edition (VBScript).

Set myInspectors= Application.Inspectors


Similar Articles