none
RunAllRules autoexec RRS feed

  • Question

  • Is there a settable preference to RunAllRules or RunAllJunkRules when Outlook opens or on a schedule? Seems to be an obviously desirable off-the-shelf setting/option. Why wouldn't you want your rules run automatically to Autoclean Junk. So far I've seen a reference to putting VBA code in ThisOutlookSession. Is that the way it would be done if it's done?

    Is there a reason you wouldn't want Autoclean? It just saves steps to navigating to Run All Rules, which is apparently required due to some rules requiring non filtering of spam. Is it considered a "best practice" not to Autoclean?

    Thanks,

    Jnana


    Jnana Sivananda

    Sunday, November 18, 2012 3:40 PM

Answers

All replies

  • There isn't a specific method to run all rules, but you can loop through Store.Rules and call Rule.Execute on each rule to run them:

    Managing Rules in the Outlook Object Model [Outlook 2007 Developer Reference]:
    http://msdn.microsoft.com/en-us/library/office/bb206763(v=office.12).aspx

    Automatically emptying the Junk E-mail folder is strictly a user-preference type of thing - I don't see any harm in doing it automatically (short of not being given the chance to confirm that each message is junk).


    Eric Legault MVP (Outlook)
    About me...
    Try Outlook Appins - affordable and easy to use!

    • Marked as answer by Jnana Monday, November 19, 2012 5:30 PM
    Monday, November 19, 2012 3:51 PM
    Moderator
  • Either a COM addin or startup code in ThisOutlookSession would be needed.
     
    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Jnana" <=?utf-8?B?Sm5hbmE=?=> wrote in message news:447a7dcf-e093-49bc-b299-0bd512dbcfa4...

    Is there a settable preference to RunAllRules or RunAllJunkRules when Outlook opens or on a schedule? Seems to be an obviously desirable off-the-shelf setting/option. Why wouldn't you want your rules run automatically to Autoclean Junk. So far I've seen a reference to putting VBA code in ThisOutlookSession. Is that the way it would be done if it's done?

    Is there a reason you wouldn't want Autoclean? It just saves steps to navigating to Run All Rules, which is apparently required due to some rules requiring non filtering of spam. Is it considered a "best practice" not to Autoclean?

    Thanks,

    Jnana


    Jnana Sivananda


    Ken Slovak MVP - Outlook
    Monday, November 19, 2012 4:10 PM
    Moderator
  • When does ThisOutlookSession code get run? Or another way to put it, how do I autoexec the code when I start Outlook or, perhaps, every day at Noon?Thanks,

    Jnana


    Jnana Sivananda

    Monday, November 19, 2012 5:37 PM
  • If macros are enabled for the VBA project and the code is in the Application_Startup() handler in ThisOutlookSession the code would run when Outlook started up.
     
    For a timed approach you would need to use a Win32 API timer class and module, VBA provides no such control and you cannot run Outlook code from a task scheduler.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Jnana" <=?utf-8?B?Sm5hbmE=?=> wrote in message news:96257f5a-602f-4431-806d-fe74e621c446...

    When does ThisOutlookSession code get run? Or another way to put it, how do I autoexec the code when I start Outlook or, perhaps, every day at Noon?Thanks,

    Jnana


    Jnana Sivananda


    Ken Slovak MVP - Outlook
    Monday, November 19, 2012 7:23 PM
    Moderator
  • Eric mentions "There isn't a specific method to run all rules, but you can loop through Store.Rules and call Rule.Execute on each rule to run them:"

    Is there a way to only run the rule if the message was a read status, and leave the unread messages alone in the Inbox?

    JMData Consultant

    Thursday, February 27, 2014 7:11 PM
  • You could iterate each Rule and decide whether or not to run it.

    If the rule was run it would run on everything within its scope. If the rule left unread items alone it would do so when run from code, if not it would do whatever on those items.

    Your decision whether or not to run the rule would be the only choice.


    Ken Slovak MVP - Outlook

    Thursday, February 27, 2014 8:09 PM
    Moderator