Table object (Outlook)

Represents a set of item data from a Folder or Search object, with items as rows of the table and properties as columns of the table.

Remarks

The Table represents a read-only dynamic rowset of data in a Folder or Search object. Use Folder.GetTable or Search.GetTable to obtain a Table object that represents a set of items in a folder or search folder. If the Table object is obtained from Folder.GetTable, you can further specify a filter (in Table.Restrict) to obtain a subset of the items in the folder. If you don't specify any filter, you'll obtain all the items in the folder.

By default, each item in the returned Table contains only a default subset of its properties. You can regard each row of a Table as an item in the folder, each column as a property of the item, and the Table as an in-memory lightweight rowset that allows fast enumeration and filtering of items in the folder. Although additions and deletions of the underlying folder are reflected by the rows in the Table, the Table does not support any events for adding, changing, and removing of rows. If you require a writeable object from the Table row, obtain the Entry ID for that row from the default EntryID column in the Table and then use the GetItemFromID method of the NameSpace object to obtain a full item, such as a MailItem or ContactItem, that supports read-write operations. For more information on default columns in a Table, see Default Properties Displayed in a Table Object.

For more information on the Table object, see Enumerating, Searching, and Filtering Items in a Folder.

Example

The following code sample illustrates how the Table object can return a filtered set of items based on their LastModificationTime property. It also shows how to list the default properties as well as specific properties of the items.

Sub DemoTable() 
 
 'Declarations 
 
 Dim Filter As String 
 
 Dim oRow As Outlook.Row 
 
 Dim oTable As Outlook.Table 
 
 Dim oFolder As Outlook.Folder 
 
 
 
 'Get a Folder object for the Inbox 
 
 Set oFolder = Application.Session.GetDefaultFolder(olFolderInbox) 
 
 
 
 'Define Filter to obtain items last modified after May 1, 2005 
 
 Filter = "[LastModificationTime] > '5/1/2005'" 
 
 'Restrict with Filter 
 
 Set oTable = oFolder.GetTable(Filter) 
 
 
 
 'Remove all columns in the default column set 
 
 oTable.Columns.RemoveAll 
 
 'Specify desired properties 
 
 With oTable.Columns 
 
 .Add ("Subject") 
 
 .Add ("LastModificationTime") 
 
 'PR_ATTR_HIDDEN referenced by the MAPI proptag namespace 
 
 .Add ("http://schemas.microsoft.com/mapi/proptag/0x10F4000B") 
 
 End With 
 
 
 
 'Enumerate the table using test for EndOfTable 
 
 Do Until (oTable.EndOfTable) 
 
 Set oRow = oTable.GetNextRow() 
 
 Debug.Print (oRow("Subject")) 
 
 Debug.Print (oRow("LastModificationTime")) 
 
 Debug.Print (oRow("http://schemas.microsoft.com/mapi/proptag/0x10F4000B")) 
 
 Loop 
 
End Sub

Methods

Name
FindNextRow
FindRow
GetArray
GetNextRow
GetRowCount
MoveToStart
Restrict
Sort

Properties

Name
Application
Class
Columns
EndOfTable
Parent
Session

See also

Table Object Members Outlook Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.