AutoFormatRule.Filter Property (Outlook)
Returns or sets a String value that represents the filter for a custom formatting rule. Read/write.
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.
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.
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