Redigera

Dela via


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

Name
AfterWrite
AttachmentAdd
AttachmentRead
AttachmentRemove
BeforeAttachmentAdd
BeforeAttachmentPreview
BeforeAttachmentRead
BeforeAttachmentSave
BeforeAttachmentWriteToTempFile
BeforeAutoSave
BeforeCheckNames
BeforeDelete
BeforeRead
Close
CustomAction
CustomPropertyChange
Forward
Open
PropertyChange
Read
ReadComplete
Reply
ReplyAll
Send
Unload
Write

Methods

Name
AddBusinessCard
ClearConversationIndex
ClearTaskFlag
Close
Copy
Delete
Display
Forward
GetConversation
MarkAsTask
Move
PrintOut
Reply
ReplyAll
Save
SaveAs
Send
ShowCategoriesDialog

Properties

Name
Actions
AlternateRecipientAllowed
Application
Attachments
AutoForwarded
AutoResolvedWinner
BCC
BillingInformation
Body
BodyFormat
Categories
CC
Class
Companies
Conflicts
ConversationID
ConversationIndex
ConversationTopic
CreationTime
DeferredDeliveryTime
DeleteAfterSubmit
DownloadState
EntryID
ExpiryTime
FlagRequest
FormDescription
GetInspector
HTMLBody
Importance
InternetCodepage
IsConflict
IsMarkedAsTask
ItemProperties
LastModificationTime
MarkForDownload
MessageClass
Mileage
NoAging
OriginatorDeliveryReportRequested
OutlookInternalVersion
OutlookVersion
Parent
Permission
PermissionService
PermissionTemplateGuid
PropertyAccessor
ReadReceiptRequested
ReceivedByEntryID
ReceivedByName
ReceivedOnBehalfOfEntryID
ReceivedOnBehalfOfName
ReceivedTime
RecipientReassignmentProhibited
Recipients
ReminderOverrideDefault
ReminderPlaySound
ReminderSet
ReminderSoundFile
ReminderTime
RemoteStatus
ReplyRecipientNames
ReplyRecipients
RetentionExpirationDate
RetentionPolicyName
RTFBody
Saved
SaveSentMessageFolder
Sender
SenderEmailAddress
SenderEmailType
SenderName
SendUsingAccount
Sensitivity
Sent
SentOn
SentOnBehalfOfName
Session
Size
Subject
Submitted
TaskCompletedDate
TaskDueDate
TaskStartDate
TaskSubject
To
ToDoTaskOrdinal
UnRead
UserProperties
VotingOptions
VotingResponse

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.