none
Create rule with VS2010(vb.net) for Conditional Formatting with Outlook Calendar 2007/2010(add-in) RRS feed

  • Question

  •  

    Hi,
    I'm trying to add rules to change colors for appointments on the "calendar" in Outlook 2007/2010.  Basically I want to programmatically add rules in "Conditional Formatting" to search for text in the subject field, nothing to do with inbox/outbox. I've found plenty of examples and documentation for the rules that are stored in the DefaultStore. Does anyone know where the Calendar rules are stored so I can access them with my code.  I know how to do it with the built in menus but can't get anywhere trying to code it in vb.net using VS2010. Any clue would be helpful and an example would even be better.

    Thanks for your help,
    Bob

    Friday, February 15, 2013 2:36 PM

Answers

  • Auto-formatting is not available as part of the Rules object model, and that applies only to mail items anyway.

    What you are looking for is actually auto-formatting on a view in the Calendar folder, not a rule per se. Unfortunately that's also not exposed to us. We can create and use custom views, but we can't add auto-formatting using code.

    To see what you have with a customized view use code like this in the Outlook VBA project to see the view XML, which is stored as an hidden item in a hidden folder named IPM_COMMON_VIEWS. The MessageClass would be "IPM.Microsoft.FolderDesign.NamedView" and the Subject of the hidden item is the view name. The auto-formattng is stored in a binary blob property PR_VIEW_STATE, which to my knowledge is undocumented.


    Ken Slovak MVP - Outlook

    • Marked as answer by Bob Bestvina Monday, February 18, 2013 7:04 PM
    Friday, February 15, 2013 9:19 PM
  • Sorry, you can use something like this in the Immediate window of the Outlook VBA project to get the current view XML:
     
    ? Application.ActiveExplorer.CurrentView.XML
     
    That will work to print the view XML to the Immediate window. You can copy the text into Notepad or any other editor to view it better.
     
    I don't think you'll get it to work, I've never seen anyone get it work for autoformatting that wasn't exposed in the object model. If you do somehow get it working what you come up with probably would work on any computer (at least with the same setup).

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Bob Bestvina" <=?utf-8?B?Qm9iIEJlc3R2aW5h?=> wrote in message news:6573557a-b10a-4ec0-a402-51ba9d5a3311...

    Ken,

       Thanks for the reply.  I do have a few more questions.  Did you mean to attach some code because you said "use code like this"?  Also if I did get this to work would I still see the same results when I log into a different machine using exchange like I see when I use the Conditional Formatting?

    Thanks again for your help,

    Bob


    Ken Slovak MVP - Outlook
    • Marked as answer by Bob Bestvina Monday, February 18, 2013 7:03 PM
    Monday, February 18, 2013 6:43 PM

All replies

  • Auto-formatting is not available as part of the Rules object model, and that applies only to mail items anyway.

    What you are looking for is actually auto-formatting on a view in the Calendar folder, not a rule per se. Unfortunately that's also not exposed to us. We can create and use custom views, but we can't add auto-formatting using code.

    To see what you have with a customized view use code like this in the Outlook VBA project to see the view XML, which is stored as an hidden item in a hidden folder named IPM_COMMON_VIEWS. The MessageClass would be "IPM.Microsoft.FolderDesign.NamedView" and the Subject of the hidden item is the view name. The auto-formattng is stored in a binary blob property PR_VIEW_STATE, which to my knowledge is undocumented.


    Ken Slovak MVP - Outlook

    • Marked as answer by Bob Bestvina Monday, February 18, 2013 7:04 PM
    Friday, February 15, 2013 9:19 PM
  • Ken,

       Thanks for the reply.  I do have a few more questions.  Did you mean to attach some code because you said "use code like this"?  Also if I did get this to work would I still see the same results when I log into a different machine using exchange like I see when I use the Conditional Formatting?

    Thanks again for your help,

    Bob

    Saturday, February 16, 2013 12:11 AM
  • Sorry, you can use something like this in the Immediate window of the Outlook VBA project to get the current view XML:
     
    ? Application.ActiveExplorer.CurrentView.XML
     
    That will work to print the view XML to the Immediate window. You can copy the text into Notepad or any other editor to view it better.
     
    I don't think you'll get it to work, I've never seen anyone get it work for autoformatting that wasn't exposed in the object model. If you do somehow get it working what you come up with probably would work on any computer (at least with the same setup).

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Bob Bestvina" <=?utf-8?B?Qm9iIEJlc3R2aW5h?=> wrote in message news:6573557a-b10a-4ec0-a402-51ba9d5a3311...

    Ken,

       Thanks for the reply.  I do have a few more questions.  Did you mean to attach some code because you said "use code like this"?  Also if I did get this to work would I still see the same results when I log into a different machine using exchange like I see when I use the Conditional Formatting?

    Thanks again for your help,

    Bob


    Ken Slovak MVP - Outlook
    • Marked as answer by Bob Bestvina Monday, February 18, 2013 7:03 PM
    Monday, February 18, 2013 6:43 PM
  • Ken,

       Thanks you have been very helpful!!!

    Thanks again,

    Bob

    Monday, February 18, 2013 7:05 PM
  • Bob!

    I know this is old! And Hope you are well when this message reaches you : )

    Were you able to auto format? If so, is there a ny chance that you can share code?

    I have required on a project a task just like this where Outlook add in must change font color settings for certain emails, and that's done with conditional formatting.

    If the case pls kindly share code or provide recommendations, cheers!

    ---Sergio

    Tuesday, March 21, 2017 2:35 AM