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

GabrielCucut
GabrielCucut used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

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

Commented:
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.

Author

Commented:
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"
        ...
        olkAppt.Save
    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.


automatic-formatting.png
Top Expert 2010
Commented:
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