共用方式為


Item Method

Returns an object from a collection. The following table shows the collections supported and the object type returned.

Collection Object Returned
Actions Action
AddressEntries AddressEntry
AddressLists AddressList
Attachments Attachment
Conflicts Conflict
Exceptions Exception
Explorers Explorer
Folders MAPIFolder
Inspectors Inspector
ItemProperties ItemProperty
Items Outlook item
Links Link
OutlookBarGroups OutlookBarGroup
OutlookBarShortcuts OutlookBarShortcut
Pages Page
Panes Pane
PropertyPages PropertyPage
Selection Outlook item
SyncObjects SyncObject
Recipients Recipient
UserProperties UserProperty
Views View
All other Microsoft Outlook collections A generic Object representing a single object in the specified collection

expression**.Item(Index)**

*expression   * Required. An expression that returns a valid collection object.

Index    Required Variant. Either the index number of the object, or a value used to match the default property of an object in the collection.

Example

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example uses the Count property and Item method of the Selection collection returned by the Selection property to display the senders of all messages selected in the active explorer window. To run this example without errors, select items of type MailItem only. Other types such as ReportItem do not have the SenderName property and will cause an error.

Sub GetSelectedItems()
    Dim myOlApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim MsgTxt As String
    Dim x As Integer
    MsgTxt = "You have selected items from: "
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
    For x = 1 To myOlSel.Count
        MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & ";"
    Next x
    MsgBox MsgTxt
End Sub

The following example adds the public folder Internal to the user's Favorites folder by using the AddToPFFavorites method.

Sub AddToFavorites()
    'Adds a Public Folder to the List of favorites
    Dim olapp As Outlook.Application
    Dim objFolder As Outlook.MAPIFolder
    Set olapp = Outlook.Application
    Set objFolder = olapp.Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders.Item("GroupDiscussion").Folders.Item("Standards").Folders.Item("Internal")
    objFolder.AddToPFFavorites
End Sub

Applies to | Actions Object | AddressEntries Object | AddressLists Object | Attachments Object | Conflicts Object | Exceptions Object | Explorers Object | Folders Object | Inspectors Object | ItemProperties Collection | Items Object | Links Object | OutlookBarGroups Object | OutlookBarShortcuts Object | Pages Object | Panes Object | PropertyPages Object | Recipients Object | Reminders Collection | Results Collection | Selection Object | SyncObjects Object | UserProperties Object | Views Collection

See Also | Links Object | Links Property