Unlike with previous versions of Outlook, Outlook 2002 includes the Outlook View control. You do not need to download additional components to get the View control on a machine. The Outlook 2002 View control offers some new functionality. For example, it provides direct view manipulation and supports a limited number of events. Table 8-1 lists the new properties of the Outlook 2002 View control.
Note | You cannot use the Outlook 2002 View control on a computer with only Outlook 2000. The Outlook View Control is the same between Outlook 2002 and 2003. |
Property | Description |
---|---|
EnableRowPersistence | A Boolean property that specifies whether the View control will remember the last row selected. It works only when hosted in Outlook. The default value is False . |
Filter | A string property that applies a SQL-style filter to the view. For more information about the format of the filter, see Chapter 18. This property replaces the entire view with the results of the filter and persists the changes to the view. |
FilterAppend | A string property that is the filter to append to a view. The filter you apply is appended to the view filter as a logical AND statement. This property does not persist the changes to the view. |
ItemCount | Returns the number of items in the folder currently displayed in the view. |
Selection | Returns the Outlook Selection object, which refers to the items currently selected in the view. |
ViewXML | Returns or sets the XML view descriptor used to render the view. For more information on view descriptors, see Chapter 18. |
Table 8-2 describes the new events supported by the Outlook 2002 View control.
Event | Description |
---|---|
Activate | Fires when the View control becomes the active element. |
BeforeViewSwitch | A cancelable event that fires before the user switches to a new view in the control programmatically or through the user interface. |
SelectionChange | Used in conjunction with the Selection property. This event fires when the selection changes in the control. |
ViewSwitch | Fires after the user switches the view programmatically or through the user interface. |
If the View control is hosted in a Web page, you should use it directly inside Outlook. This is the only way that code run within the control can access the Outlook object model. If you use Visual Basic or an Office Form to host the View control, you can always access the Outlook object model from the control. If you are hosting the control in a Web page outside Outlook, functionality such as the View property will not work; you must set the View property programmatically rather than attempt to set it as a parameter of the control in your HTML object tag.
The following samples show how to use some of the new properties and events in the View control. Notice that Boolean properties in Outlook filters take as False and 1 as True . Also, you should host this application in an Outlook folder home page. If you host it in Internet Explorer, the View control will be locked down for security reasons. For example, many of the parameters you pass in the object tag will be ignored. You must script the values for the parameters, as shown here:
<html> <head> <title>Outlook 2003 View Control Sample</title> </head> <Script Language="vbscript"> Sub Window_Onload() Set oApp = oViewControl.OutlookApplication If oApp is nothing Then MsgBox "This application does not work in IE directly!" End If End Sub Sub AppendFilter oViewControl.Filter = """urn:schemas:httpmail:read"" = 0" document.all.FilterAppend.disabled = True End Sub Sub NewFilter 'Set the new filter oViewControl.Filter = " (""DAV:isfolder"" = False AND " & _ """DAV:ishidden"" = False AND ""urn:schemas:httpmail:read"" = 0)" document.all.NewFilter.disabled = True End Sub Sub oViewControl_SelectionChange MsgBox "There are currently " & oViewControl.Selection.Count & _ " item(s) selected in the view!" End Sub </script> <body> <H1>Outlook .NET View Control Sample</H1> <hr> Click the buttons below to see the new properties and events of the Outlook .NE T View Control in action. Change selections to see the selectionchange event i n action. <p> <input type=button id=NewFilter value="Use NewFilter (Only unread items will be shown)" onclick="NewFilter"> <BR> <input type=button id=FilterAppend value="Use FilterAppend (Only unread items w ill be shown)" onclick="AppendFilter"><BR> <input type=button id=DisplayXML value="Display View XML" onclick="vbscript:MsgBox oViewControl.ViewXML"> <object classid="clsid:0006F063-0000-0000-C000-000000000046" id="oViewControl" width="774" height="489"> <param name="folder" value="SPS Sync" <param name="Namespace" value="MAPI"> <param name="Restriction" value=""> <param name="DeferUpdate" value="0"> </object> </p> </body> </html>