Views Property

Returns the Views collection object of the MAPIFolder object.


*expression   * Required. An expression that returns one of the objects in the Applies To list.


The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example creates an instance of the Views collection and displays the XML definition of a view called "Table View". If the view does not exist, it creates one.

Sub DisplayViewDef()
'Displays the XML definition of a View object

    Dim olApp As Outlook.Application
    Dim objName As Outlook.NameSpace
    Dim objViews As Outlook.Views
    Dim objView As Outlook.View

    Set olApp = New Outlook.Application
    Set objName = olApp.GetNamespace("MAPI")
    Set objViews = objName.GetDefaultFolder(olFolderInbox).Views
    'Return a view called Table View if it already exists, else create one
    Set objView = objViews.Item("Table View")
    If objView Is Nothing Then
          Set objView = objViews.Add("Table View", olTableView, olViewSaveOptionAllFoldersOfType)
    End If
    MsgBox objView.XML
End Sub

Applies to | MAPIFolder Object

See Also | View Object | Views Collection | ViewType Property