Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5060
  • Last Modified:

schedule outlook 2007 rules to run at night

I have a blackberry now and want all my new emails to go to my inbox during the day so i can see them ansd then at night have them moved to the correct folders for storage.  How can i hav ethe rules created and not set to run and then trigger them on a schdule which a script or something.
0
AxiServices
Asked:
AxiServices
1 Solution
 
David LeeCommented:
Hi, AxiServices.

The code below will turn all rules on or off.  Are you familiar with Outlook scripts?
Sub RuleSwitch(bolOn As Boolean)
    Dim olkRules As Outlook.Rules, _
        olkRule As Outlook.Rule
    Set olkRules = Outlook.Session.DefaultStore.GetRules
    For Each olkRule In olkRules
        olkRule.Enabled = bolOn
    Next
    olkRules.Save
End Sub
 
Sub RulesOn()
    RuleSwitch True
End Sub
 
Sub RulesOff()
    RuleSwitch False
End Sub

Open in new window

0
 
AxiServicesAuthor Commented:
i am a little, but i think i would need to invoke the "run now" command rather then turn them on bc i dont want them on , i just want to move everything at 1 am.  Could this be changed to just invoke?
0
 
David LeeCommented:
Sorry, maybe I misunderstood.

"How can i hav ethe rules created and not set to run"
This sounded to me like you want the rules turned off, i.e. "not set to run" during the day so "all my new emails to go to my inbox"

"then trigger them on a schdule"
Sounds like turn the rules back on when you aren't in the office.

Running the rules once per day at 1 AM is possible, but it doesn't sound like what you were asking for.  I don't mind making the change, I just want to make sure I understand what it is you want.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
AxiServicesAuthor Commented:

Yeah just like the title says "schedule outlook 2007 rules to run at night"  I basically want to run them at night and have them off all other times.  Sorry for the confusion.

Thanks in advance!
0
 
David LeeCommented:
You can close the question and create a new one if you want to, but it's not necessary.  I was still planning to post a solution here.  
0
 
AxiServicesAuthor Commented:
OK. Will keep it open.  Thanks!
0
 
AxiServicesAuthor Commented:
Please see above.
0
 
David LeeCommented:
This is the code for running rules.  .  Follow these instructions to implement it.

1.  Open Notepad.
2.  Copy the code in the snippet and paste it into Notepad.
3.  Edit the code as needed.  I placed comments where things can/need to change.
4.  Save the file with a .vbs extension.
5.  Test the script by double-clicking it.  All of your rules should execute.
6.  Create a scheduled task using Windows Task Scheduler.
7.  Set the task to run this script.

You still need the original code to turn rules off when you leave and turn them back on when you return to the office.  If the rules are not turned off, then they will continue executing when you don't wnat them to.
'Change the following three constants as desired
Const SHOW_PROGRESS = True
Const INCLUDE_SUBFOLDERS = False
Const UNREAD_MSGS_ONLY = 2
Dim olkApp, olkSes, olkFolder, olkRule
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNameSpace("MAPI")
'Change Outlook on hte next line to the name of your mail profile'
olkSes.Logon "Outlook"
Set olkFolder = olkSes.GetDefaultFolder(6)
For Each olkRule In olkSes.DefaultStore.GetRules
    olkRule.Execute SHOW_PROGRESS, olkFolder, INCLUDE_SUBFOLDERS, UNREAD_MSGS_ONLY
Next
Set olkRule = Nothing
Set olkFolder = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing

Open in new window

0
 
AxiServicesAuthor Commented:
Sounds great, let me try it and get back to you.  Thanks!

0
 
AxiServicesAuthor Commented:
ok, i changed the variable "UNREAD_MSGS_ONLY" from 2 to 1 becuase my blackbery marks the mail as read, so i wants all moved.  Looks like its working perfectly.  Thanks!
0
 
David LeeCommented:
You're welcome.  Glad I could help.
0
 
ftctekCommented:
Thank you, this helped me as well.
0
 
Peak-SupportCommented:
Is there a way to run this on email in the Inbox for the last 48 hours?
Because If I get it to schedule at the end of each day. I do not need it to rescan the older ones.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now