About the Microsoft View Control Object Model

Microsoft® Outlook® 2000 and Outlook 2002 include an object model to support programmatic access to the features in the Microsoft Outlook View Control. Outlook 2002 has new and improved features in the View Control and this documentation describes the object model of the View Control that ships with Outlook 2002. However, note that the Outlook 2002 View Control object model comprises the Outlook 2000 object model and the new properties, methods, and events. Therefore, this documentation can be used as both an Outlook 2000 View Control and an Outlook 2002 View Control reference.


Code Examples

HTML Environments

The Microsoft® Outlook® View Control is primarily designed to be used in an HTML page, such as an Outlook folder home page. In HTML, you can use the <OBJECT> tag, and then set the properties of the control by using parameters.

Folder and View Example

Create New Outlook Items Example

Visual Basic and Visual Basic for Applications Environments

You can also add the Outlook View Control to a custom form in Microsoft Visual Basic® or Visual Basic for Applications and set the properties of the control programmatically.

Date Navigation Example

Address Book Example

Inbox Subfolder Example


Address Book Example

The following example illustrates how simple it is to create a Microsoft® Visual Basic® application that opens the address book, switches filter, and changes the current view.

Here's the code in the General Declarations section of the sample Visual Basic project:

Private Sub cmdAddressBook_Click()
    ViewCtl1.AddressBook
End Sub

Private Sub cmdChangeView_Click()
    ViewCtl1.Folder = "Inbox"
    ViewCtl1.View = "Messages with AutoPreview"
End Sub

Private Sub cmdFilter_Click()
    ViewCtl1.Filter = "urn:schemas:httpmail:subject = 'test'"
End Sub

Private Sub cmdFilterOff_Click()
    ViewCtl1.Filter = """DAV:isfolder"" = False And ""DAV:ishidden"" = False"
End Sub

Private Sub Form_Load()
    ViewCtl1.Folder = "Inbox"
End Sub

This example demonstrates the use of the AddressBook method, and the View and Filter properties of the View Control.


Create New Outlook Items Example

The following example illustrates how to let users create new Microsoft® Outlook® items programmatically in a Web browser.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE>View Control</TITLE>
        <META http-equiv=Content-Type content="text/html; charset=windows-1252">
        <META content="Microsoft FrontPage 5.0" name=GENERATOR>
    </HEAD>
    <SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
        <!--
        Sub cmdNewTask_OnClick()
            ViewCtl1.NewTask
        End Sub
        -->
    </SCRIPT>
    <BODY>
        <INPUT TYPE = "SUBMIT" NAME = "cmdNewTask" VALUE = "New Task">
        <OBJECT id=ViewCtl1 classid=CLSID:0006F063-0000-0000-C000-000000000046
width="100%" height=430>
            <PARAM NAME="Folder" VALUE="Tasks">
        </OBJECT>
    </BODY>
</HTML>

In this example, the NewTask method is used to create and display a new task.


Date Navigation Example

The following example illustrates how to navigate to a specific date programmatically in the browser using Microsoft® Visual Basic®, Scripting Edition (VBScript).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE>View Control</TITLE>
        <META http-equiv=Content-Type content="text/html; charset=windows-1252">
        <META content="MSHTML 5.50.4522.1800" name=GENERATOR>
    </HEAD>
    <BODY>
        <INPUT TYPE = "SUBMIT" NAME = "cmdGotoDate" VALUE = "GoToDate">
        <OBJECT id=ViewCtl classid=CLSID:0006F063-0000-0000-C000-000000000046
width="100%" height=430></OBJECT>
        <SCRIPT language=VBScript>
            Sub cmdGotoDate_OnClick()
                ViewCtl.GotoDate "01/01/2001"
            End Sub
            Sub Window_onLoad()
                ViewCtl.Folder = "Calendar"
            End Sub
        </SCRIPT>
    </BODY>
</HTML>

In this example, the Folder property is used to set the current folder to Calendar and the GotoDate method is used to navigate to the specified date (01/01/2001).


Folder and View Example

The following example illustrates how to set which folder and view to display in the Web browser.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE>View Control</TITLE>
        <META http-equiv=Content-Type content="text/html; charset=windows-1252">
        <META content="MSHTML 5.50.4522.1800" name=GENERATOR>
    </HEAD>
    <BODY>
        <OBJECT id=ViewCtlFolder classid=CLSID:0006F063-0000-0000-C000-000000000046
width="100%" height=430><PARAM NAME="Folder" VALUE="Inbox"></OBJECT>
    </BODY>
</HTML>
In this example, the Folder property is used to set the current folder to Inbox.


Inbox Subfolder Example

The following sample illustrates how to create a Microsoft® Visual Basic® for Applications macro that creates a subfolder of the Inbox and associates it with a folder home page that hosts a View Control.

Here's the code in the General Declarations section of the sample macro:

Sub AddViewControlSubFolder()
    Dim outApp As New Outlook.Application
    Dim nsp As Outlook.NameSpace
    Dim mpfInbox As Outlook.MAPIFolder
    Dim mpfNewFolder As Outlook.MAPIFolder

    Set nsp = outApp.GetNamespace("MAPI")
    Set mpfInbox = nsp.GetDefaultFolder(olFolderInbox)
    Set mpfNewFolder = mpfInbox.Folders.Add("ViewControlInside")

    mpfNewFolder.WebViewURL = "file:C:\VCFolder.htm"
    mpfNewFolder.WebViewOn = True
    mpfNewFolder.Display
End Sub

This example creates a subfolder of the Inbox called ViewControlInside and assigns the folder home page VCFolder.htm as the WebViewURL for the newly created folder, turns the Web view on, and displays the folder.


DataCtl Object

The DataCtl object is used to get data from Outlook Today. It is a Data Source Object (DSO) that you can use for data binding, and it is not related to the View Control.


ObjModelCtl Object

The ObjModelCtl object is used to provide access to the Microsoft® Outlook® object model from an Outlook Today page (or any other). It is not related to the View Control.


ViewCtl Object

The Microsoft® Outlook® View Control displays information about a specific folder and can be integrated into solutions to provide access to Outlook data. The ViewCtl object allows programmatic access to the View Control. The control can be placed in any container that supports ActiveX® controls, including an HTML page, a Microsoft Visual Basic® form, a Microsoft Visual Basic for Applications UserForm, or a custom Outlook form. You can programmatically set the control's properties to customize the folder and view that is displayed in the control.

Using the ViewCtl Object

You can use the control to create a variety of solutions that are designed to integrate Outlook data. For example, you can place multiple view controls on an HTML page so that a user can view the contents of more than one folder within a single window. This can be useful in a scenario where you want to display calendar information for more than one user at once.

To use the ViewCtl object in your code, you need to set a reference to the View Control's type library.

To set a reference to the View Control's type library:

  1. In the Visual Basic for Applications Code Editor, on the Tools menu, click References. The References command on the Tools menu is available only when a Module window is open and active in Design view.
  2. Select the Microsoft Outlook View Control check box.


Activate Event

Occurs when a View Control becomes the active element on the page, either as a result of user action or through program code. This event does not fire on Microsoft® Visual Basic® forms.

Applies To

ViewCtl object

Syntax

object_Activate()

Parameters

object

Required. An expression that returns a ViewCtl object.


BeforeViewSwitch Event

Occurs before Microsoft® Outlook® changes the view applied to the folder displayed in the View Control element, either as a result of user action or through program code. You can cancel this event to prevent the user from changing the view in the View Control element. This event is not available in Microsoft Visual Basic® Scripting Edition (VBScript).

Applies To

ViewCtl object

Syntax

object_BeforeViewSwitch(ByVal newView As String, Cancel As Boolean)

Parameters

object

Required. An expression that returns a ViewCtl object.

newView

Required. The name of the view the View Control is switching to.

Cancel

Optional. False when the event occurs. If the event procedure sets this argument to True, the switch is cancelled and the current view is not changed.


SelectionChange Event

Occurs when the selection of the current view changes. Other selection changes (such as the selected folder) do not cause this event to occur. In addition, this event does not occur if the current folder is a file-system folder or if Outlook Today or any folder with a current Web view is displayed. This event is not available in Microsoft® Visual Basic® Scripting Edition (VBScript).

Applies To

ViewCtl object

Syntax

object_SelectionChange()

Parameters

object

Required. An expression that returns a ViewCtl object.


ViewSwitch Event

Occurs when Microsoft® Outlook® changes the view applied to the folder displayed in the View Control element, either as a result of user action or through program code.

Applies To

ViewCtl object

Syntax

object_ViewSwitch()

Parameters

object

Required. An expression that returns a ViewCtl object.


AddressBook Method

Displays the Microsoft® Outlook® Address Book dialog box.

Applies To

ViewCtl object

Syntax

object.AddressBook()

Parameters

object

Required. An expression that returns a ViewCtl object.


AddToPFFavorites Method

Adds the current public folder to the user’s Microsoft® Exchange Server Favorites public folder.

Applies To

ViewCtl object

Syntax

object.AddToPFFavorites()

Parameters

object

Required. An expression that returns a ViewCtl object.


AdvancedFind Method

Displays the Microsoft® Outlook® Advanced Find dialog box.

Applies To

ViewCtl object

Syntax

object.AdvancedFind()

Parameters

object

Required. An expression that returns a ViewCtl object.


Categories Method

Displays the Microsoft® Outlook® Categories dialog box for the currently selected item or items in the control, allowing the user to select categories for the selected items or to modify the master category list.

Applies To

ViewCtl object

Syntax

object.Categories()

Parameters

object

Required. An expression that returns a ViewCtl object.


CollapseAllGroups Method

Collapses (closes) all groups displayed in the control. If the view displayed in the control does not group items, this method has no effect.

Applies To

ViewCtl object

Syntax

object.CollapseAllGroups()

Parameters

object

Required. An expression that returns a ViewCtl object.


CollapseGroup Method

Collapses (closes) the group currently selected in the control. If the view displayed in the control does not group items, or if an item in the view is selected, this method has no effect.

Applies To

ViewCtl object

Syntax

object.CollapseGroup()

Parameters

object

Required. An expression that returns a ViewCtl object.


CustomizeView Method

Displays the Microsoft® Outlook® View Summary dialog box, allowing the user to customize the current view in the control.

Applies To

ViewCtl object

Syntax

object.CustomizeView()

Parameters

object

Required. An expression that returns a ViewCtl object.


Delete Method

After prompting the user to confirm, deletes the groups or items currently selected in the control. If one or more groups are selected, the groups and all items in the groups will be deleted.

Applies To

ViewCtl object

Syntax

object.Delete()

Parameters

object

Required. An expression that returns a ViewCtl object.


ExpandAllGroups Method

Expands (opens) all groups displayed in the control. If the view displayed in the control does not group items, this method has no effect.

Applies To

ViewCtl object

Syntax

object.ExpandAllGroups()

Parameters

object

Required. An expression that returns a ViewCtl object.


ExpandGroup Method

Expands (opens) the group currently selected in the control. If the view displayed in the control does not group items, or if an item in the view is selected, this method has no effect.

Applies To

ViewCtl object

Syntax

object.ExpandGroup()

Parameters

object

Required. An expression that returns a ViewCtl object.


FlagItem Method

Displays the Microsoft® Outlook® Flag for Follow Up dialog box for the selected item.

Applies To

ViewCtl object

Syntax

object.FlagItem()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If more than one item is selected, the dialog box applies to the last item selected.


ForceUpdate Method

Refreshes the view in the control, applying any property changes made since the DeferUpdate property was set to True.

Applies To

ViewCtl object

Syntax

object.ForceUpdate()

Parameters

object

Required. An expression that returns a ViewCtl object.


Forward Method

Executes the Forward action for the item or items selected in the control.

Applies To

ViewCtl object

Syntax

object.Forward()

Parameters

object

Required. An expression that returns a ViewCtl object.


GoToDate Method

Navigates a calendar view to a specific date.

Applies To

ViewCtl object

Syntax

object.GoToDate(newDate)

Parameters

object

Required. An expression that returns a ViewCtl object.

newDate

Required String. The date of the information you want to view.


GoToToday Method

Sets the day displayed in the control to the current day. This method affects only timeline and day/week/month views.

Applies To

ViewCtl object

Syntax

object.GoToToday()

Parameters

object

Required. An expression that returns a ViewCtl object.


GroupBy Method

Displays the Microsoft® Outlook® Group By dialog box, allowing the user to group items in the current view. This method is valid only for table-type views.

Applies To

ViewCtl object

Syntax

object.GroupBy()

Parameters

object

Required. An expression that returns a ViewCtl object.


MarkAllAsRead Method

Marks as read all items in the folder displayed in the control. The user is prompted for confirmation before any change is made.

Applies To

ViewCtl object

Syntax

object.MarkAllAsRead()

Parameters

object

Required. An expression that returns a ViewCtl object.


MarkAsRead Method

Marks as read all selected items in the control. The user is prompted for confirmation before any change is made.

Applies To

ViewCtl object

Syntax

object.MarkAsRead()

Parameters

object

Required. An expression that returns a ViewCtl object.


MarkAsUnread Method

Marks as unread all selected items in the control. The user is prompted for confirmation before any change is made.

Applies To

ViewCtl object

Syntax

object.MarkAsUnread()

Parameters

object

Required. An expression that returns a ViewCtl object.


MoveItem Method

Displays the Microsoft® Outlook® Move Items dialog box for the items selected in the control.

Applies To

ViewCtl object

Syntax

object.MoveItem()

Parameters

object

Required. An expression that returns a ViewCtl object.


NewAppointment Method

Creates and displays a new appointment.

Applies To

ViewCtl object

Syntax

object.NewAppointment()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Calendar folder, when the new appointment is saved it is saved to the folder displayed in the control. Otherwise, the appointment is saved to the user’s default Calendar folder.


NewContact Method

Creates and displays a new contact.

Applies To

ViewCtl object

Syntax

object.Contact()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Contacts folder, when the new contact is saved it is saved to the folder displayed in the control. Otherwise, the contact is saved to the user’s default Contacts folder.


NewDefaultItem Method

Creates and displays a new Microsoft® Outlook® item. The item type is the default item type for the folder displayed in the control.

Applies To

ViewCtl object

Syntax

object.NewDefaultItem()

Parameters

object

Required. An expression that returns a ViewCtl object.


NewDistributionList Method

Creates and displays a new distribution list.

Applies To

ViewCtl object

Syntax

object.NewDistributionList()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Contacts folder, when the new distribution list is saved it is saved to the folder displayed in the control. Otherwise, the distribution list is saved to the user’s default Contacts folder.


NewForm Method

Displays the Microsoft® Outlook® Choose Form dialog box, allowing a user to create a new Outlook item by selecting a form from a forms library.

Applies To

ViewCtl object

Syntax

object.NewForm()

Parameters

object

Required. An expression that return a ViewCtl object.


NewJournalEntry Method

Creates and displays a new journal entry.

Applies To

ViewCtl object

Syntax

object.NewJournalEntry()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Journal folder, when the new journal entry is saved it is saved to the folder displayed in the control. Otherwise, the journal entry is saved to the user’s default Journal folder.


NewMeetingRequest Method

Creates and displays a new meeting request.

Applies To

ViewCtl object

Syntax

object.NewMeetingrequest()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Calendar folder, when the meeting request is sent the corresponding appointment is saved to the folder displayed in the control. Otherwise, the appointment is saved to the user’s default Calendar folder. Responses to the meeting request are tallied only if the appointment is saved to the user’s default Calendar folder.


NewMessage Method

Creates and displays a new e-mail message.

Applies To

ViewCtl object

Syntax

object.NewMessage()

Parameters

object

Required. An expression that returns a ViewCtl object.


NewNote Method

Creates and displays a new note item.

Applies To

ViewCtl object

Syntax

object.NewNote()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Notes folder, when the new note is saved it is saved to the folder displayed in the control. Otherwise, the note is saved to the user’s default Notes folder.


NewOfficeDocument Method

Creates and displays a new Microsoft® Office document.

Applies To

ViewCtl object

Syntax

object.NewOfficeDocument()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

This method prompts the user to select the type of Office document to create, and then asks the user whether the document is to be sent as an e-mail message or posted to the folder displayed in the control.


NewPost Method

Creates and displays a new post item.

Applies To

ViewCtl object

Syntax

object.NewPost()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

When the user posts the message, it is posted to the folder displayed in the control. This method has no effect if the folder displayed in the control does not support messages.


NewTask Method

Creates and displays a new task.

Applies To

ViewCtl object

Syntax

object.NewTask()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the control is displaying a Tasks folder, when the new task is saved it is saved to the folder displayed in the control. Otherwise, the task is saved to the user’s default Tasks folder.


NewTaskRequest Method

Creates and displays a new task request.

Applies To

ViewCtl object

Syntax

object.NewTaskRequest()

Parameters

object

Required. An expression that returns a ViewCtl object.


Open Method

Opens the item or items currently selected in the control.

Applies To

ViewCtl object

Syntax

object.Open()

Parameters

object

Required. An expression that returns a ViewCtl object.


OpenSharedDefaultFolder Method

Displays a specified user’s default folder in the control.

Applies To

ViewCtl object

Syntax

object.OpenSharedDefaultFolder(bstrRecipient, FolderType)

Parameters

object

Required. An expression that returns a ViewCtl object.

bstrRecipient

Required String. The owner of the folder. The string must contain a display name or alias that can be resolved to a valid recipient.

FolderType

    Required OlxDefaultFolders. The type of folder. Can be one of
the following OlxDefaultFolders constants: olxFolderDeletedItems(3),
olxFolderOutbox(4), olxFolderSentMail(5), olxFolderInbox(6),
olxFolderCalendar(9),
olxFolderContacts(10), olxFolderJournal(11), olxFolderNotes(12), olxFolderTasks(13),
or olxFolderDrafts(16).

Remarks

An error occurs if the user running the control does not have permission to access the specified folder.


PrintItem Method

Prints the items currently selected in the control. If a group is selected, the items in the group are selected and printed. The Print dialog box is displayed to allow the user to specify how the items are to be printed.

Applies To

ViewCtl object

Syntax

object.PrintItem()

Parameters

object

Required. An expression that returns a ViewCtl object.


Reply Method

Executes the Reply action for the item or items selected in the control.

Applies To

ViewCtl object

Syntax

object.Reply()

Parameters

object

Required. An expression that returns a ViewCtl object.


ReplyAll Method

Executes the ReplyAll action for the item or items selected in the control.

Applies To

ViewCtl object

Syntax

object.ReplyAll()

Parameters

object

Required. An expression that returns a ViewCtl object.


ReplyInFolder Method

Creates a post item for each message currently selected in the control.

Applies To

ViewCtl object

Syntax

object.ReplyInFolder()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

The post item contains the text of the message it is replying to and has the same conversation topic.


SaveAs Method

Saves the items selected in the control as a file. The Save As dialog box is displayed to allow the user to select the location and format of the resulting file. If more than one item is selected, the items are concatenated and saved as a text file; otherwise, the user is allowed to choose from several file formats.

Applies To

ViewCtl object

Syntax

object.SaveAs()

Parameters

object

Required. An expression that returns a ViewCtl object.


SendAndReceive Method

Sends messages in the Outbox folder and checks for new messages.

Applies To

ViewCtl object

Syntax

object.SendAndReceive()

Parameters

object

Required. An expression that returns a ViewCtl object.


ShowFields Method

Displays the Microsoft® Outlook® Show Fields dialog box, allowing the user to select the fields to be displayed in the current view of the control.

Applies To

ViewCtl object

Syntax

object.ShowFields()

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

This method has no effect if the current view does not allow the user to change the fields displayed in the view.


Sort Method

Displays the Microsoft® Outlook® Sort dialog box, allowing the user to sort the contents of the control using multiple criteria.

Applies To

ViewCtl object

Syntax

object.Sort()

Parameters

object

Required. An expression that returns a ViewCtl object.


SynchFolder Method

Synchronizes the folder displayed in the control for offline use.

Applies To

ViewCtl object

Syntax

object.SynchFolder()

Parameters

object

Required. An expression that returns a ViewCtl object.


ActiveFolder Property

Returns an object representing the folder displayed in the control. If the control is not hosted in a Microsoft® Outlook® folder home page, this property returns Nothing. Read-only.

Applies To

ViewCtl object

Syntax

object.ActiveFolder

Parameters

object

Required. An expression that returns a ViewCtl object.


DeferUpdate Property

Sets or returns a Boolean indicating whether property changes affect the control display. Read/write.

Applies To

ViewCtl object

Syntax

object.DeferUpdate

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

When set to True, this property prevents changes to control properties from being displayed in the control. When set to False, this property allows the control to update to reflect current property settings.


EnableRowPersistence Property

Sets or returns a Boolean indicating whether the View Control will remember the last selected row. This property only works when the View Control is hosted within Microsoft® Outlook®. The default value is False. Read/write.

Applies To

ViewCtl object

Syntax

object.EnableRowPersistence

Parameters

object

Required. An expression that returns a ViewCtl object.


Filter Property

Returns or sets a String representing the DAV Searching and Locating (DASL) statement used to restrict the display to a specified subset of data. Read/write.

Applies To

ViewCtl object

Syntax

object.Filter

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

To reset a filter back to it's default value, you need to set the filter as:

object.Filter = " ""DAV:isfolder"" = False And ""DAV:ishidden"" = False "


FilterAppend Property

Returns or sets a String representing the additional criteria that is be added to the filter settings. Read/write.

Applies To

ViewCtl object

Syntax

object.FilterAppend

Parameters

object

Required. An expression that returns a ViewCtl object.


Folder Property

Returns or sets a String representing the path of the folder displayed by the control. Read/write String.

Applies To

ViewCtl object

Syntax

object.Folder

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

For security reasons, the return value includes the name of the root message store of the folder only if the folder is not in the user’s personal mailbox.

If neither the Namespace nor Folder properties are set and the control is contained in a Microsoft® Outlook® folder home page, the control displays the current folder. If the Namespace property is set to "MAPI" and the Folder property is not set, the control displays the user's Inbox.


ItemCount Property

Returns a Long indicating the count of objects in the current folder. Read-only.

Applies To

ViewCtl object

Syntax

object.Count

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

The ItemCount property always returns the number of items in the current folder, and not the number of items visible in the view. Setting the Filter or FilterAppend property has no effect on the value of the ItemCount property.


Namespace Property

Returns or sets a String representing the namespace property of the control. The namespace represents an abstract root object for any data source. Read/write.

Applies To

ViewCtl object

Syntax

object.NameSpace

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If neither the Namespace nor Folder properties are set and the control is contained in a Microsoft® Outlook® folder home page, the control displays the current folder. If the Namespace property is set to "MAPI" and the Folder property is not set, the control displays the user's Inbox.


OutlookApplication Property

Returns an object that represents the container object for the control. If the control is not hosted in a Microsoft® Outlook® folder home page, this property returns Nothing.

Applies To

ViewCtl object

Syntax

object.OutlookApplication

Parameters

object

Required. An expression that returns a ViewCtl object.


Restriction Property

Sets or returns a String representing a filter to the items displayed in the control, displaying only those items that match the filter. Read/write.

Applies To

ViewCtl object

Syntax

object.Restriction

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

The filter is a string expression containing one or more filter clauses joined by the logical operators And, Not, and Or.

A filter clause is a simple expression that evaluates to True or False; for example, [CompanyName] = "Microsoft".

Note that property names can be used in the expression and are identified and delimited by square brackets. Except for these bracketed property names, only literals are allowed within the expression; variables and constants are not evaluated as part of the expression.

Comparison operators allowed within the filter expression include >, <, >=, <=, = and <>. Comparisons are not case sensitive and do not include subject prefixes added when a message was replied to or forwarded. Logical operators allowed are And, Not, and Or.

Note that = is not interpreted for string comparisons as "equals", but rather as "contains," so that "[Subject] = 'Outlook'" matches all items that have "Outlook" or "outlook" anywhere in the Subject field. To create a true equality filter, you must use <= and >= together, as in this example.

OvCtl1.Restriction "[Subject] <= 'outlook' and [Subject] >= 'outlook'"

In this example, the control displays only those items whose Subject field contains only "outlook" or "Outlook."

The setting of the Restriction property does not persist if the view or current folder changes.

The Restriction property only works correctly if you use Table or Card views. This is a limitation of the Microsoft® Outlook® View Control.


Selection Property

Returns a Selection object consisting of one or more items selected in the current view.

Applies To

ViewCtl object

Syntax

object.Selection

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

If the current folder is a file-system folder, or if Outlook Today or any folder with a current Web view is currently displayed, this property returns an empty collection.


View Property

Returns or sets a String representing the name of the view in the control. Read/write.

Applies To

ViewCtl object

Syntax

object.View

Parameters

object

Required. An expression that returns a ViewCtl object.

Remarks

View names are case-sensitive. If this value is set to a string that does not exactly match the name of a view available for the current folder, the view in the control does not change.


ViewXML Property

Returns or sets a String representing the view implementation via XML. Read/write.

Applies To

ViewCtl object

Syntax

object.ViewXML

Parameters

object

Required. An expression that returns a ViewCtl object.