locked
loosing filter property in AutoFormatRules (conditional formatting) on folders. RRS feed

  • Question

  • Hi All,

    I am using vsto 4 with VS2010 and developing the addin for office2010 outlook.

    I am tring to add conditional formatting on a folder. My below code is creating the conditional formatting and showing correctly but if i am moving between folders then its loosing its condition and start showing the formatting on all the folder items. I also checked the conditional formatting at the time of creation when its working fine in outlook, i try to check the filter condition by UI but its showing nothing there.

            private static void SetFormattingRuleFor(_TableView caseView)
            {
                if (caseView == null) return;
                for (var i = 1; i <= caseView.AutoFormatRules.Count; i++)
                {
                    var rl = caseView.AutoFormatRules[i];
                    if (rl.Name == "PartialDownloaded") caseView.AutoFormatRules.Remove(i);
                }
                var rule = caseView.AutoFormatRules.Add("PartialDownloaded");
                rule.Filter = TextHelper.GetSearchField(CustomProperty.PartialDownloaded) + "\" = 1";
                rule.Font.Italic = true;
                rule.Font.Color = OlColor.olColorGray;
                rule.Enabled = true;
                caseView.Save();
                caseView.Apply();
            }
    

    If i am giving the filter condition by UI then it is keeping but if giving the filter condition from program then its loosing it.

    Does i am missing something or its any issue in VSTO. Is there any work around by Redemption because we are using redemption as well in our application.

    Thanks in advance.

    Regards
    Anand

     


    Anand
    Friday, December 2, 2011 2:57 PM

Answers

  • If Sue said it was a known issue then there's the problem, and she presented whatever workarounds there are. I don't have anything to add to what Sue said.
     
    You can try opening a support incident, but frankly if it wasn't going to be fixed when Outlook 2007 was current it's not going to be fixed now.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:cbb22baa-be63-4de5-ab93-28b97457a43e...
    Hi Ken,
    Thanks for your response but i tried both the ways by putting the @SQL and without that as well. For the loop part, your suggestion is good and i had made the changes in that. But still the same issue is happening. I searched on net and find the below link
    http://www.eggheadcafe.com/microsoft/Office-Outlook-VBA/30343407/autoformatrule-does-not-persist-named-mapi-property-filter.aspx

    In the link Sue Moser said that this is a known limitation. My issue is similar to the issue mentioned in the link above.
    Find below my new code
            private static void SetFormattingRuleForCaseView(_TableView caseView)
            {
                for (var i = caseView.AutoFormatRules.Count; i >= 0; i--)
                {
                    var rl = caseView.AutoFormatRules[i];
                    if (rl.Name == "PartialDownloaded") caseView.AutoFormatRules.Remove(i);
                }
                var rule = caseView.AutoFormatRules.Add("PartialDownloaded");
                rule.Filter = "@SQL=\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyProperty\" = 1";
    
                rule.Font.Italic = true;
                rule.Font.Color = OlColor.olColorGray;
                rule.Enabled = true;
                caseView.Save();
                caseView.Apply();
            }
    

    Still the same issue is coming, that it is creating the Conditional Formatting but not keeping any filter criteria in that. Since i find this method to create conditional formatting, so i commited for the same but now its not working as expected and making problem for delivery.
    Can you please check and if there is any alternate solution for that, then please let me know.
    Regards
    Anand.

    Anand

    Ken Slovak MVP - Outlook
    • Marked as answer by 许阳(无锡) Monday, December 26, 2011 12:23 PM
    Thursday, December 8, 2011 2:49 PM

All replies

  • Hi Anand,

     

    Thanks for posting in the MSDN Forum.

     

    Would you please clarify the variable “CustomProperty”? Please tell me this variable comes from where and when it will be clean.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, December 5, 2011 8:53 AM
  • Hi Tom,

    Sorry for confusion as CustomProperty is a constants class and GetSearchField is method to get formatting string, the actual output line will looks like below

    rule.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyProperty\" = 1";

    Where MyProperty is a Yes/No user property which all mail items are having in that folder.

    At the time of folder creation we are adding this property in that and calling the above method to set the formatting rule.

    Regards
    Anand.

     

     


    Anand
    Monday, December 5, 2011 10:02 AM
  • 2 points.
     
    According to the Help on DASL filters you must precede any DASL filter, except when it's being used in an AdvancedSearch(), with "@SQL=".
     
    When removing items from a collection in a For loop make sure to use a downcounting loop. Otherwise you'd end up processing only some of the items in the collection and not the entire collection.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:bf2af1a7-ddf8-4b92-9cc6-375b9264cb47...

    Hi Tom,

    Sorry for confusion as CustomProperty is a constants class and GetSearchField is method to get formatting string, the actual output line will looks like below

    rule.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyProperty\" = 1";

    Where MyProperty is a Yes/No user property which all mail items are having in that folder.

    At the time of folder creation we are adding this property in that and calling the above method to set the formatting rule.

    Regards
    Anand.

     

     


    Anand

    Ken Slovak MVP - Outlook
    Monday, December 5, 2011 3:29 PM
  • Hi Ken,
    Thanks for your response but i tried both the ways by putting the @SQL and without that as well. For the loop part, your suggestion is good and i had made the changes in that. But still the same issue is happening. I searched on net and find the below link
    http://www.eggheadcafe.com/microsoft/Office-Outlook-VBA/30343407/autoformatrule-does-not-persist-named-mapi-property-filter.aspx

    In the link Sue Moser said that this is a known limitation. My issue is similar to the issue mentioned in the link above.
    Find below my new code
            private static void SetFormattingRuleForCaseView(_TableView caseView)
            {
                for (var i = caseView.AutoFormatRules.Count; i >= 0; i--)
                {
                    var rl = caseView.AutoFormatRules[i];
                    if (rl.Name == "PartialDownloaded") caseView.AutoFormatRules.Remove(i);
                }
                var rule = caseView.AutoFormatRules.Add("PartialDownloaded");
                rule.Filter = "@SQL=\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyProperty\" = 1";
    
                rule.Font.Italic = true;
                rule.Font.Color = OlColor.olColorGray;
                rule.Enabled = true;
                caseView.Save();
                caseView.Apply();
            }
    

    Still the same issue is coming, that it is creating the Conditional Formatting but not keeping any filter criteria in that. Since i find this method to create conditional formatting, so i commited for the same but now its not working as expected and making problem for delivery.
    Can you please check and if there is any alternate solution for that, then please let me know.
    Regards
    Anand.

    Anand
    Thursday, December 8, 2011 5:54 AM
  • If Sue said it was a known issue then there's the problem, and she presented whatever workarounds there are. I don't have anything to add to what Sue said.
     
    You can try opening a support incident, but frankly if it wasn't going to be fixed when Outlook 2007 was current it's not going to be fixed now.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:cbb22baa-be63-4de5-ab93-28b97457a43e...
    Hi Ken,
    Thanks for your response but i tried both the ways by putting the @SQL and without that as well. For the loop part, your suggestion is good and i had made the changes in that. But still the same issue is happening. I searched on net and find the below link
    http://www.eggheadcafe.com/microsoft/Office-Outlook-VBA/30343407/autoformatrule-does-not-persist-named-mapi-property-filter.aspx

    In the link Sue Moser said that this is a known limitation. My issue is similar to the issue mentioned in the link above.
    Find below my new code
            private static void SetFormattingRuleForCaseView(_TableView caseView)
            {
                for (var i = caseView.AutoFormatRules.Count; i >= 0; i--)
                {
                    var rl = caseView.AutoFormatRules[i];
                    if (rl.Name == "PartialDownloaded") caseView.AutoFormatRules.Remove(i);
                }
                var rule = caseView.AutoFormatRules.Add("PartialDownloaded");
                rule.Filter = "@SQL=\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyProperty\" = 1";
    
                rule.Font.Italic = true;
                rule.Font.Color = OlColor.olColorGray;
                rule.Enabled = true;
                caseView.Save();
                caseView.Apply();
            }
    

    Still the same issue is coming, that it is creating the Conditional Formatting but not keeping any filter criteria in that. Since i find this method to create conditional formatting, so i commited for the same but now its not working as expected and making problem for delivery.
    Can you please check and if there is any alternate solution for that, then please let me know.
    Regards
    Anand.

    Anand

    Ken Slovak MVP - Outlook
    • Marked as answer by 许阳(无锡) Monday, December 26, 2011 12:23 PM
    Thursday, December 8, 2011 2:49 PM
  • Hi Anand,

    I wonder if you got solution to this issue. I am working on similar case where I need to set filter on meeting subject.

    Please let me know if you resolved it and its working for you.

    Thanks,

    Sureshh


    sureshh...

    Monday, May 14, 2012 8:27 PM
  • Hello Friends,

    After trying couple of ways I could resolve this issue myself. you can follow below code to fix such issue. The only problem is that it will not show this AutoFormatRule filter in the Outlook Manage View UI but gets set correctly.

    This one is for custom CalendarView. This code allows you to color (Teal) all meetings/appointments in your calendar with subject that contains word 'test' :

    private void CreateAutoFormatRule() { foreach (var view in _explorer.CurrentFolder.Views) { var calendarView1 = view as CalendarView; if (calendarView1 != null && "MyTestView" == calendarView1.Name) //Search if there exists the old view { calendarView1.Delete(); //Delete existing view first break; } } //Create new test view var calendarView = _explorer.CurrentFolder.Views.Add("MyTestView", OlViewType.olCalendarView, OlViewSaveOption.olViewSaveOptionAllFoldersOfType) as CalendarView; if (calendarView != null) calendarView.CalendarViewMode = OlCalendarViewMode.olCalendarViewWeek; //Create own test rule AutoFormatRule afr = calendarView.AutoFormatRules.Add("MyTestRule"); afr.Filter = "\"urn:schemas:contacts:subject\" like '%test%'"; //Add filter afr.Font.ExtendedColor = OlCategoryColor.olCategoryColorTeal; //Add font color afr.Enabled = true; calendarView.AutoFormatRules.Save(); //Save AutoFormatRules for test view calendarView.Save(); //Save View calendarView.Apply(); //Apply new test view }

    Thanks,
    Sureshh


    sureshh...


    • Edited by sureshh Tuesday, May 15, 2012 8:27 PM
    Tuesday, May 15, 2012 8:26 PM
  • Hi,

    I'm facing the same issue as Anand (I'm on Outlook 2010).

    When adding a new autoformatrule to a folder view programmatically, the filter property is not properly set it seems, with the result that the rule is applied to all items in the folder, not just the ones selected by the filter expression.

    For example:

    var view = application.activeExplorer.curentFolder.currentView;
    var rule = view.autoFormatRules.add("Underline tests");
    rule.font.underline = true;
    rule.filter = "\"urn:schemas:httpmail:subject\" LIKE '%test%'";
    rule.enabled = true;
    view.save();

    Effects:

    * All items underlined, not just the ones with word "test" in subject.

    * In the Conditional Formatting dialog in the Outlook UI, the Filter dialog looks empty.

    * In the debugger, if I call view.autoFormatRules("Underline tests").filter after the view.save() statement, the error message "Invalid procedure call or argument" is printed to the console.

    In a previous reply from Ken, reference is made to a post by Sue on an issue relating to persistence of programmatically created autoformatrules across Outlook sessions. That seems to discuss a different issue, so reply is not a clarification.

    Grateful for any clarification!

    Thanks,

    Mats

     

    Monday, April 18, 2016 10:47 AM
  • Does it help if after you create the rule you get a new instance of the current view and Apply it?

    Also, what happens if you switch the view from the current folder to a different folder and then back again after you enable the rule?


    Ken Slovak MVP - Outlook

    Monday, April 18, 2016 1:32 PM
  • Thanks Ken for prompt response! I am not sure I understand fully. Would you able to post an example?
    Monday, April 18, 2016 2:02 PM
  • 1. After View.Save(),

    view = application.activeExplorer.curentFolder.currentView;

    view.Apply();

    2. In the UI switch to viewing another folder, then switch back and see what the view shows.


    Ken Slovak MVP - Outlook

    Monday, April 18, 2016 2:21 PM
  • Hi Ken,

    It seems necessary to apply the view in an unusual way, as you hinted, for the conditional formatting to be applied, however, still the filter is being ignored!

    I've included a test case below in case this helps you understand the issue better. Simply save the code below to an HTML document, create a subfolder in Outlook for testing purposes, set the folder homepage of the folder to the HTML file, and put a few messages in the folder, a few of them with the word "test" in the subject, view the folder and see the effect.

    Thanks,
    Mats

    <html>
        <head>
            <title>Outlook Folder Homepage - Testing Conditional Formatting</title>
            <script type="text/javascript">
                function init() {
                    try {
                        ovc.folder = ovc.outlookApplication.activeExplorer.currentFolder.folderPath;
                        if (ovc.activeFolder.views.item("My View"))
                            ovc.activeFolder.views.remove("My View")
                        var view = ovc.activeFolder.views.add("My View", 0, 1);
                        ovc.view = view.name;
                        var rule = view.autoFormatRules.add("My Underline Test Rule");
                        rule.font.underline = true;
                        rule.filter = "@SQL=" + "\"" + "urn:schemas:httpmail:subject" + "\"" + " like '%test%'";
                        rule.enabled = true;
                        view.autoFormatRules.save();
                        alert("autoFormatRule.Filter (before view.Save()) = " + getFilter());
                        view.save();
                        try {
                            alert("autoFormatRule.Filter (after view.Save()) = " + getFilter());
                        } catch(e) {
                            alert("Note: Failed to access autoFormatRule.Filter property after view.Save(). Error message: " + e.description);
                        }
                        // ovc.view = "Test View" -- seems not to successfully apply the view, but with a setTimeout() it does!
                        setTimeout("ovc.view = 'My View'", 1000); 
                        // After delay, the conditioanl formatting is applied to all items in the folder, ignoring the filter!!!
                    }
                    catch(e) {
                        alert("An error occurred: " + e.description) 
                    }
                }
                function getFilter() {
                    return ovc.activeFolder.views.item("My View").autoFormatRules.item("My Underline Test Rule").filter;
                }
            </script>
        </head>
        <body onload="init()">
            <object classid="CLSID:0006F063-0000-0000-C000-000000000046" id="ovc" height="100%" width="100%" 
                codebase="http://activex.microsoft.com/activex/controls/office/outlctlx.CAB#ver=9,0,0,3203">
                <param name="Namespace" value="MAPI" />
            </object>
        </body>
    </html>


    • Edited by Matsew Monday, April 18, 2016 7:16 PM Put code example into code block.
    Monday, April 18, 2016 3:57 PM
  • I'll take a closer look at it tomorrow.

    Ken Slovak MVP - Outlook

    Monday, April 18, 2016 9:05 PM
  • When the rule is created and you go to the new folder view, the Filter property is null. In that case the formatting is applied to all items in the folder. So the problem is the filter property is not being persisted.

    The only workaround I can think of for that would be to delete and then re-create the rule whenever a folder where you want the rule to be applied becomes current. A possible trigger event could be the Explorer.BeforeFolderSwitch() event.

    I'll test this later on Outlook 2013 and 2016, my tests so far have been on Outlook 2010. As that version is out of mainstream support there's no chance any such bug will be fixed for Outlook 2010. If the same bug exists on Outlook 2013/2016 I'll file a bug report on that. But for 2010 it is what it is.


    Ken Slovak MVP - Outlook

    Tuesday, April 19, 2016 1:21 PM
  • The word I get from the Outlook product group is that this will not be fixed. You can try the workaround I suggested and see if that works for you.

    Here's the information I was given:

    "It looks like this issue has come up before in bug OfficeQFE 34094.  It was won’t fixed because it was too risky.  I’m not sure we would get it reconsidered in the newer versions but if pressing the customer should open a support case to request the change. 

    The Outlook team has determined that taking a change to satisfy this request runs a high likelihood of regressing legacy behavior across previous Outlook version. This degree of risk cannot be sufficiently mitigated in a sustained engineering release in order to deliver a quality release to all Outlook customers."


    Ken Slovak MVP - Outlook

    Tuesday, April 19, 2016 3:45 PM
  • Thanks Ken for your help investigating this issue.

    One thing I need to stress is that in my case it is not a problem at all if the rule does not persist after closing Outlook, navigation away from the current folder or switching to a different view. (I understand that there exists a known issue related to persistence of rules across Outlook sessions, and which might even be by design, however, this is not the problem I am having). I need however that it be possible to add and apply a conditional formatting rule in an existing or new view until the user switches to a different view or navigates away from the folder. Currently it seems possible to add the rule, however, only the formatting is applied while the condition is being ignored.

    Does the response which you received from the Outlook product team and the bug "OfficeQFE 34094"relate to the issue of persisting rules across Outlook sessions (which is not a problem for me) or to the issue of rules not being saved/applied correctly (which _is_ a problem for me)? Since the response mentions it would be "risky to fix it due to regressing legacy behavior", it sounds like it is referring to the former issue. Would you be able to clarify this?

    Many thanks for your support!

    Mats

    Tuesday, April 19, 2016 8:08 PM
  • The actual problem is that the autoformat rule.Filter property is empty and returns a runtime error when accessed. That causes the format condition to be applied to all items in the folder.

    That's what MS won't fix, the filter persistence, which is the root cause of the various issues involved.

    You can open a support case if you want, but I know the result will be "won't fix". If the product group hasn't been willing to risk trying to fix these issues since at least Outlook 2010 it won't happen now.


    Ken Slovak MVP - Outlook

    Wednesday, April 20, 2016 1:19 PM
  • Thanks for the clarification Ken!

    Concerning possible workarounds, somewhere I think somebody suggested that the conditional formatting rules are stored in a hidden item in the user's mailbox. Thinking whether it might be possible to have that item written/saved programmatically as a way to apply some custom pre-defined rules...? Maybe not the cleanest/safest workaround, but...

    Mats

    Wednesday, April 20, 2016 1:38 PM
  • Unfortunately the situation is worse than just one missing filter. The same thing applies to all autoformat rules, as pointed out by Dmitry:

    set folder = Application.ActiveExplorer.CurrentFolder

    set view = folder.CurrentView

    set afrules = view.AutoFormatRules

    for each rule in afrules

      Debug.Print rule.Name

      Debug.Print rule.Filter

      Debug.Print "--------------"

    next

    The named view properties are stored in hidden items under IPM_COMMON_VIEWS under IMsgStore, but the filter is missing there when I looked at it.


    Ken Slovak MVP - Outlook

    Wednesday, April 20, 2016 2:05 PM
  • Wondering if deviating to another API, e.g. EWS, could work...?
    Thursday, April 21, 2016 6:58 AM
  • EWS doesn't deal with the Outlook UI, so that wouldn't help at all. The Outlook REST API's don't have anything for this either. Extended MAPI doesn't deal with the UI, I can't think of any alternative API's that would help.

    Ken Slovak MVP - Outlook

    Friday, April 22, 2016 2:53 PM
  • Update on this problem for those still interested.  I'm currently developing a VSTO for Office 2016 and can confirm that the problem still exists.  When a AutoFormatRule is programmatically created and added to a view, the formatting of the rule is applied to all items in the view because the filter of the view is not created correctly.  For me this affects both the immediate use of the view, and also its persistence to a subsequent Outlook session (as experienced by MatSew above)

    I have a partial solution, which is to create the rule, save it, re-add the filter, apply it and finally re-add the filter again.  See the code snippet below which is a function to add a filter based on crmLinkState custom attribute to the current view.  It expects to be passed a reference to the ActiveExplorer.

            private void CreateAutoFormatRule(Explorer olExplorer)
            {
                // Convert the Outlook view into a COM _TableView class which as the AutoFormatRules exposed as properties
                // return if this cast cannot be done
                _TableView tv = olExplorer.CurrentView as _TableView;
                if (tv == null) return;
                // Try to find an existing AutoFormatRule for CRM Tracking and exit if you find one
                AutoFormatRule afr = tv.AutoFormatRules["CRM Tracking Pending"];
                if (afr != null) return;
                //Add a new rule and then configure it
                AutoFormatRule nafr = tv.AutoFormatRules.Add("CRM Tracking Pending");
                nafr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
                nafr.Font.Italic = true;
                nafr.Font.Bold = true;
                nafr.Font.Color = OlColor.olColorGreen;
                nafr.Enabled = true;
                // Save and apply the changes to the rule
                tv.Save();
                nafr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
                tv.Apply();
                nafr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
            }

    Tuesday, January 28, 2020 2:03 PM
  • For me this fix didn't work.  Creating a new view with an AutoFormatRule has exactly the same effect as simply adding an AutoFormatRule to the existing view.  It might be that things are different with CalendarViews, I'm working with TableViews.  I can create my AutoFormatRule, which works immediately for the user, but will revert next time they switch explorer / view and then switch back again.  The AutoFormatRule filter is created in a corrupted state.
    Tuesday, January 28, 2020 4:58 PM
  • There is a solution to this problem, albeit a bit messy.  It is definitely an Outlook bug that causes programmatically created AutoFormatRules (View Conditional Formatting through the Outlook UI) to be created in a semi-corrupt state which won't persist a change of view or re-load of the application.  You can work round the issue by adding an event handler to the Explorer.ViewSwitch event which deletes and re-creates the AutoFormatRule every time the view is changed.  This will make it appear as if your conditional formatting rule is working fine.

    We've used this technique to implement conditional formatting which highlights emails which are pending tracking to Dynamics CRM by having a conditional formatting rule based on the value of crmLinkState custom attribute on the mail items.

        public partial class BrethertonsAddIn
        {
            Outlook.Explorer _activeExplorer;
    
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                _activeExplorer = this.Application.ActiveExplorer();
                _activeExplorer.ViewSwitch += BrethertonsAddIn_ViewSwitch;
                BrethertonsAddIn_ViewSwitch();
            }
    
            private void BrethertonsAddIn_ViewSwitch()
            {
                Outlook.Explorer olExplorer = Application.ActiveExplorer();
                // Convert the Outlook view into a COM _TableView class which as the AutoFormatRules exposed as properties
                // return if this cast cannot be done
                Outlook._TableView tv = olExplorer.CurrentView as Outlook._TableView;
                if (tv == null) return;
                // Try to find an existing AutoFormatRule for CRM Tracking and delete it
                // Use of the loop is necessary as there is no delete method on the AutoFormatRule object
                // So it's necessary to use the Remove method of a collection object instead
                for (int n = tv.AutoFormatRules.Count; n > 1; n--)
                {
                    if (tv.AutoFormatRules[n].Name == "CRM Tracking Pending")
                    {
                        tv.AutoFormatRules.Remove(n);
                    }
                }
                //Add a new rule and then configure it
                Outlook.AutoFormatRule afr = tv.AutoFormatRules.Add("CRM Tracking Pending");
                afr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
                afr.Font.Italic = true;
                afr.Font.Bold = true;
                afr.Font.Color = Outlook.OlColor.olColorGreen;
                afr.Enabled = true;
                // Save and apply the changes to the rule
                tv.Save();
                afr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
                tv.Apply();
                afr.Filter = "\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/crmLinkState\" = 1";
            }
       }

    Wednesday, January 29, 2020 4:48 PM