MailItem Object

Outlook Developer Reference

Represents a mail message in an Inbox folder.

Remarks

Use the CreateItem method to create a MailItem object that represents a new mail message.

Use Items (

index

), where

index

is the index number of a mail message or a value used to match the default property of a message, to return a single MailItem object from an Inbox folder.

Example

The following example creates and displays a new mail message.

Visual Basic for Applications
  Set myItem = Application.CreateItem(olMailItem)
myItem.Display

The following example sets the current folder as the Inbox and displays the second mail message in the folder.

Visual Basic for Applications
  Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display

See Also