Share via


AutoFormatRule.Filter Property

Outlook Developer Reference

Returns or sets a String value that represents the filter for a custom formatting rule. Read-write.

Version Information
 Version Added:  Outlook 2007

Syntax

expression.Filter

expression   A variable that represents an AutoFormatRule object.

Remarks

The value of this property is a DAV Searching and Locating (DASL) string that represents the current filter for the custom formatting rule. For more information about using DASL to filter items formatted by the formatting rule, see Filtering Items. Setting this property to an empty string applies the custom formatting rule to all items displayed by the view.

Bb206814.vs_note(en-us,office.12).gif  Note
This property returns an empty string for a standard formatting rule (an AutoFormatRule object with a Standard property value set to True). An error occurs if you attempt to assign a value to this property for a standard formatting rule.

Example

The following Visual Basic for Applications (VBA) example obtains a View object by using the CurrentView property of the Explorer object, and then creates a new AutoFormatRule named "Handoff Messages." The Filter property of the AutoFormatRule object is set so that the formatting rule applies to any message in which the Subject property value starts with "HANDOFF". The sample then sets the properties of the Font object for the AutoFormatRule object the so that messages to which the formatting rule applies are displayed in blue, bold, 8 point Courier New text.

Visual Basic for Applications
  Private Sub FormatHandoffMessages()
    Dim objView As TableView
    Dim objRule As AutoFormatRule
    
    ' Check if the current view is a table view.
    If Application.ActiveExplorer.CurrentView.ViewType = olTableView Then
    
        ' Obtain a TableView object reference to the current view.
        Set objView = Application.ActiveExplorer.CurrentView
        
        ' Create a new rule that displays any message with a
        ' subject line that starts with "HANDOFF" in
        ' blue, bold, 8 point Courier New text.
        Set objRule = objView.AutoFormatRules.Add("Handoff Messages")
        With objRule
            .Filter = """http://schemas.microsoft.com/mapi/proptag/0x0037001f""" & _
                " CI_STARTSWITH 'HANDOFF'"
            With .Font
                .Name = "Courier New"
                .Size = "8"
                .Bold = True
                .Color = olColorBlue
            End With
        End With
        
        ' Save and apply the table view.
        objView.Save
        objView.Apply
    End If
End Sub

See Also