Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 889
  • Last Modified:

Autoreply based on time of day

I'd like to set up a mailbox to send an autoreply only during certain hours - every time except for Monday to Friday 8-5, and specific holidays (like thanksgiving).

I see no time of day options in the built-in mailbox rules.  Anyone got a way to make this work?
1 Solution
here's a tool that may work for you:

Otherwise, there may be a way to script a solution...
nummagumma2Author Commented:
That's a great looking tool, but it will require manual interaction every day (turning on the rule).  Hmmm.
Hi nummagumma2,
Can you set it up as a scheduled task?

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

nummagumma2Author Commented:
James - I'm a little confused.  How could I set up a scheduled task to turn on the "Out of office autreply" rule?
David LeeCommented:
Greetings, nummagumma2.

> How could I set up a scheduled task to turn on the "Out of office autreply" rule?
I can do it with a bit of scripting.

nummagumma2Author Commented:
That'd be pretty sweet.   I have some existing Javascript that selects the date/time that I want - since I really want to exclude M-F outside of 8-5 and also all federal holidays we observe.  I'm using it to display on a website that offers a form that feeds into this mailbox.

Would it be possible to take the same logic and apply it to your custom script so that it does the 'deed' during the 'off' time and then undoes it during the 'on' time?  Could your custom script activate/deactivate a rule on the mailbox instead of the OOOAR?

Here's that JScript:

function ISHDin () {
      // get date
      var dt_date=new Date();
      // check for hours outside 8 - 5 PST
      var dayofweek = dt_date.getUTCDay();
      var hourofday = (dt_date.getUTCHours()-8);
      if (hourofday <=0) var hourofday=hourofday+24
      if (dayofweek == 0
            || dayofweek == 6
            || hourofday < 8
            || hourofday >= 17
            )return true;

     // check simple dates (month/date - no leading zeroes)
     var n_date = dt_date.getDate(),
          n_month = dt_date.getMonth() + 1;
     var s_date1 = n_month + '/' + n_date;
     if (   s_date1 == '1/1'   // New Year's Day
          || s_date1 == '7/4'   // Independence Day
          || s_date1 == '12/25' // Christmas Day
     ) return true;
     // weekday from beginning of the month (month/num/day)
     var n_wday = dt_date.getDay(),
          n_wnum = Math.floor((n_date - 1) / 7) + 1;
     var s_date2 = n_month + '/' + n_wnum + '/' + n_wday;
     if ( s_date2 == '2/3/1'  // President's Day, third Monday in February
        || s_date2 == '9/1/1'  // Labor Day, first Monday in September
          || s_date2 == '11/4/4' // Thanksgiving Day, fourth Thursday in November
          || s_date2 == '11/4/5' // Thanksgiving Day, fourth Thursday in November
     ) return true;

     // weekday number from end of the month (month/num/day)
     var dt_temp = new Date (dt_date);
     dt_temp.setMonth(dt_temp.getMonth() + 1);
     dt_temp.setDate(dt_temp.getDate() - 1);
     n_wnum = Math.floor((dt_temp.getDate() - n_date - 1) / 7) + 1;
     var s_date3 = n_month + '/' + n_wnum + '/' + n_wday;
     if (   s_date3 == '5/1/1'  // Memorial Day, last Monday in May
     ) return true;

     return false;

David LeeCommented:
Up through Outlook 2003 there's no means of scripting rules, to include turning them off and on.  (Outlook 2007 is supposed to offer this capability.)  That does not include the OOO assistant though.  It can be turned on/off in a script.  That's the closest I can get.  
nummagumma2Author Commented:
Ok.  So, turning on/off the OOAR on a schedule is better than nothin'
David LeeCommented:

The script below will turn the OOO message on.  You can create a second script to turn the OOO message off simply by changing this line

    objMAPISession.OutOfOffice = True


    objMAPISession.OutOfOffice = False

To use this script copy and paste the code into Notepad and save the file with a .vbs extension.  You can then create a scheduled task and have it run the code.  The task will have to run under a set of credintials that has an Outlook profile defined on the computer the task is running on.  The script will also need the profile name and password embeded in it.  Or you could get creative and add code to read them from some source.  However you choose to do this though the script has to have both in order to log in to Outlook.

Dim objMAPISession
Set objMAPISession = CreateObject("MAPI.Session")
'Change the profile name and password on the following line
objMAPISession.Logon "MyOutlookProfileName", "MyOutlookProfilePassword", False, True
objMAPISession.OutOfOffice = True
'Change the text of the out of office message on the next line as desired
objMAPISession.OutOfOfficeText = "I'm out of the office right now."
Set objMAPISession = Nothing
nummagumma2Author Commented:
Untested, but I'll assume it works.... would deal with hours via schedule, but not holidays.  No time to test and want to award points for effort.
David LeeCommented:
When you do get around to testing it, let me know if you run into any problems and I'll be glad to help you work through them.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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