Today, while checking questions on Experts-Exchange, I stumbled across one where the author is looking for a way to forward messages during certain times of the day. S/he had found a potential solution on another blog, but was unable to get it to work. I had a look at that solution, and while it’s both clever and functional, I think there’s a simpler way to go about this and that’s to use a macro.
If you’ve looked at the other solution, then you may have noticed a couple of potential issues. Things such as
- The rule includes the year, which would require you to edit the rule once a year to keep It current.
- The rule keys on the hour, making it impossible to handle something like 11:45am to 12:15pm.
- The rule doesn’t handle a range very well. Instead of being able to specify something like from 5:00pm until 12:00am it would require you to enter in each hour between 5:00pm and 12:00am.
- The rule would fire if it found the time string (e.g. 2011: 23) anywhere in the message header, not just in the received time.
If the rule Dan outlined ran at the server, then it would have a big advantage over a rule/macro combination since macros are client-side only. But, Dan’s rule is also client-side only which, in my opinion, gives the macro approach a distinct advantage.
The macro below solves all of the problems I described above. It only looks at the time, so you don’t have to edit it from year to year. It can handle any time-frame imaginable, and handles ranges quite well. Since the macro is checking the time when the rule is triggered, there’s no possibility of a false positive. With a little extra coding you could even give the macro the ability to forward to different people at different times or on different days.
Outlook 2003 or later.
Follow these instructions to add the code to Outlook.
- Start Outlook
- Press ALT + F11 to open the Visual Basic Editor
- If not already expanded, expand Microsoft Office Outlook Objects
- If not already expanded, expand Modules
- Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert → Module.
- Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
- Click the diskette icon on the toolbar to save the changes
- Close the VB Editor
Sub ForwardAtCertainTimes(Item As Outlook.MailItem) 'On the next line, edit the address to forward to Const FWD_TO = "firstname.lastname@example.org" Dim bolFwd As Boolean, olkFwd As Outlook.MailItem Select Case Time 'On the next line, edit the time range(s) during which you want to forward messages Case #12:00:00 AM# To #7:59:59 AM#, #12:00:00 PM# To #12:59:59 PM#, #5:00:00 PM# To #11:59:59 PM# bolFwd = True End Select If bolFwd Then Set olkFwd = Item.Forward olkFwd.To = FWD_TO olkFwd.Send End If End Sub
Using this solution.
- Create a rule that fires for all messages.
- Set the rule’s action to run a script and select ForwardAtCertainTimes as the script to run.
Dear David, I would like to get in touch with you regarding certain solutions which I would need your advice on for a mobile app / web platform that my company is developing. How may i get in touch with you please? Thank you very much. (Genuinely need help here, not a spam for sure!) – Brynner
I’ve sent you an email. You can reach me at that address. You should know up front that I’m not an expert on either mobile apps or web platforms.