次の方法で共有


Folder.GetTable Method (Outlook)

Obtains a Table object that contains items filtered by Filter.

Version Information

Version Added: Outlook 2007

Syntax

expression .GetTable(Filter, TableContents)

expression A variable that represents a Folder object.

Parameters

Name

Required/Optional

Data Type

Description

Filter

Optional

String

A filter in Microsft Jet or DAV Searching and Locating (DASL) syntax that specifies the criteria for items in the parent Folder.

TableContents

Optional

OlTableContents

Specifies the type of items in the folder that GetTable returns. The default is olUserItems.

Return Value

A Table that contains items in the parent Folder that meet the criteria in Filter. By default, TableContents is olUserItems and the returned Table contains only the filtered items that are not hidden.

Remarks

If Filter is a blank string or the Filter parameter is omitted, GetTable returns a Table with rows representing all the items in the Folder. If Filter is a blank string or the Filter parameter is omitted and TableContents is olHiddenItems, GetTable returns a Table with rows representing all the hidden items in the Folder.

For more information on filters, see Filtering Items and Referencing Properties by Namespace.

GetTable returns a Table with the default column set for the folder type of the parent Folder. To modify the default column set, use the Add, Remove, or RemoveAll methods of the Columns collection object. When TableContents is olHiddenItems, the default column set is always the default column set for a mail folder even though the parent Folder might be, for example, a Contacts folder. For more information on default column sets, see Default Properties Displayed in a Table Object.

You can use Table.Restrict to apply subsequent filters to a Table that is based on the Folder object.

Example

The following code sample illustrates how to use Folder.GetTable to obtain a Table object based on the LastModificationTime of items in the Inbox. It then enumerates and prints the values of a couple of default properties of these 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)  
  
    'Enumerate the table using test for EndOfTable  
    Do Until (oTable.EndOfTable)  
        Set oRow = oTable.GetNextRow()  
        Debug.Print (oRow("Subject"))  
        Debug.Print (oRow("LastModificationTime"))  
    Loop  
End Sub

See Also

Concepts

Folder Object Members

Folder Object