Share via


Items Object

Outlook Developer Reference

Contains a collection of Outlook item objects in a folder.

Remarks

Use the Items property to return the Items object of a Folder object.

Use Items(

index

), where

index

is the name or index number, to return a single Outlook item.

Bb219950.vs_note(en-us,office.12).gif  Note
The items in the Items collection object are not guaranteed to be in any particular order.

Example

The following Microsoft Visual Basic for Applications (VBA) example returns the first item in the Inbox with the Subject "Need your advice."

Visual Basic for Applications
  Sub GetItem()
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolder As Outlook.Folder
    Dim myItem As Object
    
    Set myNameSpace = Application.GetNameSpace("MAPI")
    Set myFolder = _
        myNameSpace.GetDefaultFolder(olFolderInbox)
    Set myItem = myFolder.Items("Need your advice")
    myItem.Display
End sub

The following VBA example returns the first item in the Inbox. In Office Outlook 11 or later, the Items object returns the items in an Offline Folders file (.ost) in the reverse order.

Visual Basic for Applications
  Sub GetItem()
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolder As Outlook.Folder
    Dim myItem As Object
    
    Set myNameSpace = Application.GetNameSpace("MAPI")
    Set myFolder = _
        myNameSpace.GetDefaultFolder(olFolderInbox)
    Set myItem = myFolder.Items(1)
    myItem.Display
End sub

See Also