Obtain formatting (color) rules for Microsoft Outlook appointments in Visual Basic

GabrielCucut used Ask the Experts™
Is it possible to obtain the formatting rules from Visual Basic.

I would like to apply the same rules into a Visual Basic program as they are applied to colors but for other uses.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Hi, GabrielCucut.

It is possible, but I do not think it's practical.  Here is why.

1.  The Font property is read only.  Although it can be exported it cannot be set via code.
2.  There is a bug in creating autoformat rules via code.  Unless Microsoft has released a patch rules created via code aren't saved.  They exist only while viewing the folder.  The moment you navigate to another folder the rules are lost.  I haven't seen a patch for this, but I may have missed it.


I have the following code to assign a category automatically to an appointment:
Private Sub olkCalendar_ItemChange(ByVal Item As Object)
    Dim olkAppt As Outlook.AppointmentItem
    Set olkAppt = Item
    If olkAppt.Categories = "" Then
        If InStr(1, olkAppt.Subject, "THEP ") Then AddCategory olkAppt, "THEP"
        If InStr(1, olkAppt.Subject, "GIPS ") Then AddCategory olkAppt, "GIPS"
    End If
End Sub
I would like to obtain these conditions from Automatic Formatting conditions like these, so I don't have to change the code every time I create a new condition.

Top Expert 2010
The conditions don't use the same syntax.  For example, here is how an automatic formatting rule would represent the condition for a rule where you want to find the word MSDN in the subject line.

"http://schemas.microsoft.com/mapi/proptag/0x0037001f" LIKE '%MSDN%'

I don't see a practical means for using that to construct your rules for adding categories.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial