Item Method

Microsoft Outlook Visual Basic

Show All

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
Exceptions Exception
Explorers Explorer
Folders MAPIFolder
Inspectors Inspector
Items Outlook item
Links Link
OutlookBarGroups OutlookBarGroup
OutlookBarShortcuts OutlookBarShortcut
Pages Page
Panes Pane
PropertyPages PropertyPage
Selection Outlook item
SyncObjects SyncObject
Recipients Recipient
UserProperties UserProperty
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

This Visual Basic for Applications example returns the second MailItem object in the default Inbox folder. It assumes that at least two MailItem objects already exist.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set mySecondItem = myFolder.Items.Item(2)

This Visual Basic for Applications example returns the "Forward" action from the Actions collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAction = myItem.Actions.Item("Forward")

This example returns a MAPIFolder object from a Folders collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolders = myNameSpace.Folders
Set myFolder = myFolders.Item("Public Folder")

This Visual Basic for Applications example also returns a MAPIFolder object from a Folders collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myFolders = _
    myOlApp.ActiveExplorer.CurrentFolder.Folders
Set myFolder = myFolders.Item("Project X")

This Visual Basic for Applications example creates a contact, returns its empty Pages collection, adds three custom pages and then returns the first custom page from the collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myPages = myItem.GetInspector.ModifiedFormPages
myPages.Add "One"
myPages.Add "Two"
myPages.Add "Three"
Set myPage = myPages.Item("One")

This Visual Basic for Applications example creates a mail message, adds four Recipient objects, then returns the name of the third recipient from the newly-created Recipients collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myItem.Recipients
myRecipients.Add("Rich Andrews")
myRecipients.Add("Robin Hjellin")
myRecipients.Add("Meng Phua")
myRecipients.Add("Kim Yoshida")
msgbox myRecipients.Item(3).name