Columns Object (Outlook)

Represents the collection of Column objects in a Table object.

Version Added: Outlook 2007

The Columns object supports enumerating Column objects in the Columns collection object. It supports the COM interface, IEnumerable .

The following code sample illustrates how to obtain a Table object based on the LastModificationTime of items in the Inbox. It also shows how to remove the default columns of the Table, add specific columns, and print the values of the corresponding properties of these items.

Sub RemoveAllAndAddColumns() 
 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 
 'Specify desired properties 
 With oTable.Columns 
 .Add ("Subject") 
 .Add ("LastModificationTime") 
 'PR_ATTR_HIDDEN referenced by the MAPI proptag namespace 
 .Add ("") 
 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("")) 
End Sub
© 2015 Microsoft