Items Object

Microsoft Outlook Visual Basic

Items Object

Items

An object containing Microsoft Outlook item objects in a folder.

Using the Items Object

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

Use Items(index), where index is the name or index number, to return a single Outlook item.

Note  In Office Outlook 2003, the items in the Items collection object are not guaranteed to be in any particular order.

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

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items("Need your advice")
		

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

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items(1)

		

The following Microsoft Visual Basic Scripting Edition (VBScript) example returns the first item in the Inbox. In Office Outlook 2003, the Items object returns the items in an Offline Folders file (.ost) in the reverse order.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myItem = myFolder.Items(1)