MailItem Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


Aa158723.parchild(en-us,office.10).gifMailItem
Aa158723.space(en-us,office.10).gifAa158723.parchild(en-us,office.10).gif

Represents a mail message in an Inbox (mail) folder.

Using the MailItem Object

Use the CreateItem method to create a MailItem object that represents a new mail message. The following example creates and displays a new mail message.

  Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Display

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. The following example sets the current folder as the Inbox and displays the second mail message in the folder.

  Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display