Selection.Item Method

Outlook Developer Reference

Returns an Outlook item from a collection.

Syntax

expression.Item(Index)

expression   A variable that represents a Selection object.

Parameters

Name Required/Optional Data Type Description
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.

Return Value
An Object value that represents the specified object.

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.

Visual Basic for Applications
  Sub GetSelectedItems()
    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 = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
    MsgTxt = MsgTxt &amp; myOlSel.<strong>Item</strong>(x).SenderName &amp; ";"
Next x
MsgBox MsgTxt

End Sub

See Also