Item Method

Applies To

Actions collection object, Attachments collection object, Folders collection object, Items collection object, Pages collection object, Recipients collection object, UserProperties collection object.

Description

Returns the specified Action, Attachment, MAPIFolder, Outlook item, page, Recipient, or UserProperty object from its respective Actions, Attachments, Folders, Items, Pages, Recipients or UserProperties collection.

Syntax

expression.Item(Index)

expression An expression that returns an Actions, Attachments, Folders, Items, Pages, Recipients or UserProperties 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 example returns the second MailItem object in the default Inbox folder. It assumes that at least two MailItem objects already exist.

Set myFolder = _
    olNameSpace.GetDefaultFolder(olFolderInbox)
Set mySecondItem = myFolder.Items.Item(2)
This example returns the "Forward" action from the Actions collection.

Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAction = myItem.Actions.Item("Forward")
This example returns a MAPIFolder object from a Folders collection.

Set myFolders = olNameSpace.Folders
Set myFolder = myFolders.Item("Public Folder")
This example also returns a MAPIFolder object from a Folders collection.

Set myFolders = _
    myOlApp.ActiveExplorer.CurrentFolder.Folders
Set myFolder = myFolders.Item("Project X")
This example creates a contact, returns its empty Pages collection, adds three custom pages and then returns the first custom page from the collection.

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 example creates a mail message, adds four Recipient objects, then returns the third recipient from the newly-created Recipients collection and sets it as a BCC recipient.

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")
myRecipients.Item(3) = olBCC
This example returns the "Total Cost" user property from the "My Order Form" UserProperties collection.

Set myItems = myOlApp.ActiveExplorer.CurrentItem.Items
Set myItem = myItems.Add("My Order Form")
Set myProperties = myItem.UserProperties
Set myProperty = myProperties.Item("Total Cost")