Sdílet prostřednictvím


MailItem Object

MailItem
Multiple objects

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

Remarks

If a program tries to reference any type of recipient information by using the Outlook object model, a dialog box is displayed that asks you to confirm access to this information. You can allow access to the Address Book or recipient information for up to ten minutes after you receive the dialog box. This allows features, such as mobile device synchronization, to be completed.

You receive the confirmation dialog box when a solution tries to programmatically access the following properties of the MaiItem object:

  • SentOnBehalfOfName
  • SenderName
  • ReceivedByName
  • ReceivedOnBehalfOfName
  • ReplyRecipientNames
  • To
  • CC
  • BCC
  • Body
  • HTMLBody
  • Recipients
  • SenderEmailAddress

Properties | Actions Property | AlternateRecipientAllowed Property | Application Property | Attachments Property | AutoForwarded Property | AutoResolvedWinner Property | BCC Property | BillingInformation Property | Body Property | BodyFormat Property | Categories Property | CC Property | Class Property | Companies Property | Conflicts Property | ConversationIndex Property | ConversationTopic Property | CreationTime Property | DeferredDeliveryTime Property | DeleteAfterSubmit Property | DownloadState Property | EnableSharedAttachments Property | EntryID Property | ExpiryTime Property | FlagDueBy Property | FlagIcon Property | FlagRequest Property | FlagStatus Property | FormDescription Property | GetInspector Property | HasCoverSheet Property | HTMLBody Property | Importance Property | InternetCodepage Property | IsConflict Property | IsIPFax Property | ItemProperties Property | LastModificationTime Property | Links Property | MarkForDownload Property | MessageClass Property | Mileage Property | NoAging Property | OriginatorDeliveryReportRequested Property | OutlookInternalVersion Property | OutlookVersion Property | Parent Property | Permission Property | PermissionService Property | ReadReceiptRequested Property | ReceivedByEntryID Property | ReceivedByName Property | ReceivedOnBehalfOfEntryID Property | ReceivedOnBehalfOfName Property | ReceivedTime Property | RecipientReassignmentProhibited Property | Recipients Property | ReminderOverrideDefault Property | ReminderPlaySound Property | ReminderSet Property | ReminderSoundFile Property | ReminderTime Property | RemoteStatus Property | ReplyRecipientNames Property | ReplyRecipients Property | Saved Property | SaveSentMessageFolder Property | SenderEmailAddress Property | SenderEmailType Property | SenderName Property | Sensitivity Property | Sent Property | SentOn Property | SentOnBehalfOfName Property | Session Property | Size Property | Subject Property | Submitted Property | To Property | UnRead Property | UserProperties Property | VotingOptions Property | VotingResponse Property

Methods | ClearConversationIndex Method | Close Method | Copy Method | Delete Method | Display Method | Forward Method | Move Method | PrintOut Method | Reply Method | ReplyAll Method | Save Method | SaveAs Method | Send Method | ShowCategoriesDialog Method

Events | AttachmentAdd Event | AttachmentRead Event | BeforeAttachmentSave Event | BeforeCheckNames Event | BeforeDelete Event | Close Event | CustomAction Event | CustomPropertyChange Event | Forward Event | Open Event | PropertyChange Event | Read Event | Reply Event | ReplyAll Event | Send Event | Write Event

Parent Objects

Child Objects | Actions Object | Attachments Object | Conflicts Object | FormDescription Object | ItemProperties Object | Links Object | MAPIFolder Object | Recipients Object | UserProperties Object