none
Run all the rules before exiting Outlook.... RRS feed

  • Question

  • Hi,

    How can I force my Outlook Rules to be run one more time before I terminate the Outlook via TASKKILL.... I want to do this via a scheduled command, to start the Outlook and then say 20 minutes later I kill it but before killing it to run the rules one more time.


    Jeff Paarsa

    Monday, December 30, 2013 2:11 AM

All replies

  • Hello Jeff,

    Why do you need to terminate Outlook by killing its process?

    Instead, you can automate Outlook by using its Object Model that provide all the necessary properties and methods for closing the application normally. For example, the Application class provides the Quit method which closes all currently opened Outlook windows and shuts down the application. Here is what MSDN states for the Quit method:

    The associated Outlook session is closed completely; the user is logged out of the messaging system and any changes to items not already saved are discarded.

    You can run rules programmatically: the Rule class from the Outlook Object Model provides the Execute method. Please read more about this in the Controlling Outlook 2007 with C# and Visual Studio Tools for Office article. Moreover, you can create your own rules and run them on the fly.  

    Finally, you may find the Launching Office Apps Programmatically article helpful.

    Monday, December 30, 2013 11:38 AM
  • Hello Eugene,

    Well I would like to start Outlook via an scheduled task after Midnight and then after running and receiving my emails I want to exit and close it say after 30-60 minutes...  Yes if there is a way to shut it down gracefully I would prefer that, Something that can be easily be done without doing much programming... I do not have C#, Visual Studio and I do not know how it can be done via either C# or Visual Studio Tools for Office...  

    What you suggest is very nice but I was looking for something that can be done without doing too much work and programming... I am willing to pay a fee for it and buy it if the price is right... I do have a lot more project to be done and highly less time to spend too much on a project.... You have answered my other problem with faxing that leaves the very first faxes in and VBA project does not do process the very first fax that comes in and each time I have to force the Rule to be run before I close the outlook.  I have seen that problem in 2007 and 2010... Now you are telling me is a known issue... I wish at least Microsoft would come up with a work around it, for the existing known issue.

    Thanks for the guidance... I read through you suggested articles and links to see what I would learn...

     


    Jeff Paarsa

    Tuesday, December 31, 2013 5:30 AM
  • Hello Jeff,

    You can call the Quit method of the Application class from VBA too. There is no need to use VSTO or any other tools. Anyway, you could contact me via my web site (listed in the profile) for developing custom solutions if needed. 

    The known issue is only related to the NewMail and NewMailEx events. It looks like you don't use them.

    Tuesday, December 31, 2013 4:05 PM
  • Hello Eugene,

    I want to start my Outlook at 12:00 A.M. Via Scheduler when I am in bed and sleep and end it after running 30-60 minutes after mid night gracefully... I think what you suggest is via another VBA rule that runs the Quit method... But who and how can it be run when I am in bed and sleep?  Is there a way to schedule a rule to be run say after 30-60 minutes after Outlook starts running? If there is I don't know how... Can you guide me to it please if you know how it can be done?

    Regards,

    Jeff P.


    Jeff Paarsa

    Tuesday, December 31, 2013 6:58 PM
  • Hello Eugene,

    I did created RunRule but now I can only run all the rules with only one click of a button may be two, MyTab and the RunRule button and I used to do it with 4-5 button by going to the Rule button and.... But that is not what I am looking for... I want to run Outlook via scheduling a Task and run it full and clean...

    Any How thanks for your Help so far and I wish you a Happy New year...

    Regards,

    Jeff P. 


    Jeff Paarsa

    Tuesday, December 31, 2013 11:30 PM
  • Hello Jeff,

    Rules will not help in that case.

    Instead, you need to use a timer from a VBA code for closing Outlook programmatically. You can read more about this approach in the Outlook VBA - Run a code every half an hour and outlookcode forum threads.

    Wednesday, January 1, 2014 1:51 PM
  • Hi Jeff,

    What buttons are you talking about? What does RunRule stand for?

    As I wrote you above, you can run rules programmatically when Outlook starts. The Rule class from the Outlook Object Model provides the Execute method. Please read more about this in the Controlling Outlook 2007 with C# and Visual Studio Tools for Office article. Moreover, you can create your own rules and run them on the fly. You can handle the Startup event of the Application in your VBA macro and run rules programmatically.

    Wednesday, January 1, 2014 1:58 PM
  • Hi Eugene,

    I added a button to my custom ribbon that when I click on it it runs the following code.

    Public Sub RunRule()
           Dim colRules As Outlook.Rules
           Dim myRule As Outlook.Rule
           Dim myNames() As Variant
           Dim name As Variant
           
           myNames = Array("Delivered", "Failed", "SaveAttachment")

           Set colRules = Application.Session.DefaultStore.GetRules()

           For Each name In myNames()
               For Each myRule In colRules
                   ' If its a rule we want to run
                    If myRule.name = name Then
                        ' Then run it
                        myRule.Execute ShowProgress:=True
                    End If
                Next
           Next
    End Sub


    Jeff Paarsa

    Wednesday, January 1, 2014 5:38 PM
  • Hi Eugene,

    I definitely look into those codes and consider it... seems like at this time is the only option available to start and gracefully shutdown the Outlook with scheduler task...

    Regards,

    Jeff P.


    Jeff Paarsa

    Wednesday, January 1, 2014 5:40 PM
  • Hi Jeff,

    Did you have a chance to use a timer from a VBA code for running rules and closing Outlook programmatically? You can read more about this approach in the Outlook VBA - Run a code every half an hour and outlookcode forum threads.

    According to the neighbor forum thread the issue is resolved. Could you please confirm this?

    Thursday, January 2, 2014 12:35 PM
  • Hi Eugene,

    Yes I did used it and it ran perfectly first day but after that each morning I see a dialog box opened and waiting to be responded... showing "Outlook can not be quieted of stopped at this time" and still the first item attached to first email when I started the Outlook still is unattached and is in the Inbox... when I run the Strip attachment rule it brings in a lot of today's faxes that I do not want to come in...  Actually when I click on the OK button of the Dialog, Outlook crashes and restarts again!...

    I thought if I could stop processing faxes that has come the day/date that outlook has started... So I thought if I get the system date and deduct a day from it to get the Yesterday date I may be able to stop processing the faxes has been arrived recently and only process the faxes has came in during the Yesterday date...

    Well Still struggling...

    Regards,

    Jeff P.


    Jeff Paarsa

    Tuesday, January 14, 2014 3:49 AM
  • Hello Jeff,

    It looks like you need to customize the rule settings or, as a workaround, develop a VBA script for searching yesterday's faxes and moving them to the specified folder. Also you can try to increase the processing time before closing Outlook programmatically.

    Tuesday, January 14, 2014 4:06 PM
  • Hello,

    I think if I get the system date at the start of rule and subtract one from it to get back to the day before then as long as newly obtained date = objMsg.ReceivedTime then I can process and strip the PDF from it and as soon as I saw the receive item has a date bigger than Newly Obtained date then that means I should stop fax has just been arrived and it is not yesterday's fax...

    Remember I was to start my Outlook exactly at 12:00 A.M. what do you think?

    Regards, 

    Jeff. P.


    Jeff Paarsa

    Wednesday, January 15, 2014 4:35 AM
  • Hello Jeff,

    For moving yesterday's faxes you need to develop a macro. Rules don't allow filtering items based on the particular date.

    Wednesday, January 15, 2014 8:23 AM