MailItem Object (Outlook)
Published: July 16, 2012
Represents a mail message.
Use the CreateItem method to create a MailItem object that represents a new mail message.
Use the Folder.Items property to obtain an Items collection representing the mail items in a folder, and the Items.Item (index) method, 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 the specified folder.
The following Visual Basic for Applications (VBA) example creates and displays a new mail message.
Sub CreateMail() Dim myItem As Object Set myItem = Application.CreateItem(olMailItem) myItem.Subject = "Mail to myself" myItem.Display End Sub
The following VBA example sets the current folder as the Inbox and displays the second mail message in the folder. In general, the order of mail messages in a folder is not guaranteed to be in a particular order.