MailItem object (Outlook)
Represents a mail message.
Remarks
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.
Example
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.
Sub DisplayMail()
Dim myItem As Object
Dim myFolder As Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display
End Sub
Events
Methods
Name |
---|
AddBusinessCard |
ClearConversationIndex |
ClearTaskFlag |
Close |
Copy |
Delete |
Display |
Forward |
GetConversation |
MarkAsTask |
Move |
PrintOut |
Reply |
ReplyAll |
Save |
SaveAs |
Send |
ShowCategoriesDialog |
Properties
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.