XML Property

Microsoft Outlook Visual Basic

expression.XML

expression    Required. An expression that returns a View object.

Remarks

To determine how the XML should be structured when creating views, you can create a view by using the Outlook user interface and then you can retrieve the XML property for that view.

Example

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 = 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
		

Following are the modified properties that are visible in the following XML source code. In addition to the property definitions, the XML source also defines any objects that make up the view. The following example displays the XML definition of columns that appear in the above view.

<column>
<heading>Flag Status</heading>
<prop>http://schemas.microsoft.com/mapi/proptag/0x10900003</prop>
<type>i4</type>
<bitmap>1</bitmap>
<style>padding-left:3px;text-align:center;padding-left:3px</style>
</column>
<column>
<format>boolicon</format>
<heading>Attachment</heading>
<prop>urn:schemas:httpmail:hasattachment</prop>
<type>boolean</type>
<bitmap>1</bitmap>
<style>padding-left:3px;text-align:center;padding-left:3px</style>
<displayformat>3</displayformat>
</column>