Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2010 Conditional Formatting

Status
Not open for further replies.

BlueHorizon

Instructor
Jan 16, 2003
730
US
Hi everyone,

I know how to set conditional formatting to change the appearance of new emails when a certain word is in the subject. What I want to do is change the appearance if a certain word BEGINS the subject, but not when it is merely contained in the subject.

Example: If the word "Call" begins the subject line, I want it to turn red. If the word "Call" is somewhere else in the subject, I don't want it to turn red.

Any thoughts?

Best,
KV
Blue Horizon
 
Sadly Outlook doesn't support this functionality directly (neither Outlook conditional formatting nor Rules support the necessary pattern matching)

We can achieve the desired affect through some devious tricks ...

Step 1
Create a new colour category. The example uses one called 'MakeRed'

Step 2
Create a custom action that can assign a category to a mail item. Code such as the following should be put in ThisOutlookSession:

Code:
[blue]Public Sub ColourCat(Item As Outlook.MailItem)
    With Item
        Select Case .Subject <> ""
            Case InStr(LCase(.Subject), "call") = 1 [green]' matches subject starting with 'call'[/green]
                If .Categories = "" Then
                    .Categories = "MakeRed" [green]' The category we created previously[/green]
                ElseIf InStr(.Categories, "MakeRed") = 0 Then
                    Debug.Print .Categories
                    .Categories = .Categories & ", MakeRed"
                End If
            [green]'Case <a different match if you wanted>[/green]
            Case Else
        End Select
        .Save
    End With
End Sub[/blue]

Step 3
Create an Outlook rule (give it an appropriate name) that applies to all incoming messages, and which runs a script. Select the above script - ColourCat - in the script selection dialog.

Step 4
Create a conditional format that colours items red that are categorized as MakeRed

And you are done.


 
Thanks, strongm! I'll give this a try !

Best,
Blue Horizon [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top