Share via


Items.SetColumns Method

Outlook Developer Reference

Caches certain properties for extremely fast access to those particular properties of an item within the collection.

Syntax

expression.SetColumns(Columns)

expression   A variable that represents an Items object.

Remarks

The SetColumns method is useful for iterating through the Items object. If you don't use this method, Microsoft Office Outlook must open each item to access the property. With the SetColumns method, Outlook only checks the properties that you have cached. Properties which are not cached are returned empty.

SetColumns cannot be used, and will cause an error, with any property that returns an object. It cannot be used with the following properties:

AutoResolvedWinner InternetCodePage
Body MeetingWorkspaceURL
BodyFormat MemberCount
Categories ReceivedByEntryID
Children ReceivedOnBehalfOfEntryID
Class RecurrenceState
Companies ReplyRecipients
DLName ResponseState
DownloadState Saved
EntryID Sent
HTMLBody Submitted
IsConflict VotingOptions

The ConversationIndex property cannot be cached using the SetColumns method. However, this property will not result in an error like the other properties listed above.

Example

The following Visual Basic for Applications (VBA) example uses the Items collection to get the items in default Tasks folder, caches the Subject and DueDate properties and then displays the subject and due dates each in turn.

Visual Basic for Applications
  Sub SortByDueDate()
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolder As Outlook.Folder
    Dim myItem As Object
    Dim myItems As Outlook.Items
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myItems = myFolder.Items
myItems.<strong>SetColumns</strong> ("Subject, DueDate")
For Each myItem In myItems
    MsgBox myItem.Subject &amp; "  " &amp; myItem.DueDate
Next myItem

End Sub

See Also