Click here to Skip to main content
14,335,481 members

OOF Automation

Rate this:
4.60 (2 votes)
Please Sign up or sign in to vote.
4.60 (2 votes)
20 Sep 2015CPOL
Automated Setting of the Out of Office Assistant


OOF (Out Of Office) Automation is a VBScript-based automation of switching the OOF Assistant on automatically when the respective user has entered an "away" appointment and back to off when there is no "away" appointment anymore.

This works by utilizing CDO externally using the Task Scheduler, e.g. all 30 minutes. There is also an internal solution to be found at CDOLive. However, I had a MAPI problem when implementing it, as my Outlook OOF Message was suddenly out of sync with the message modified within the script.

Using the Script

Every end user wishing to participate in the automated OOF Assistant switching has to set at least one (configurable) placeholder in his OOF Message in place of a date to be displayed in his final Message (e.g. "I'm out of the office <Date>. For urgent matters, please contact my... - Kind regards, Roland").

<Date> would then be replaced by from <begin date/time> to <end date/time>. from and to can be configured in the script for two languages (currently German and English). The respective placeholders are <Datum> and <Date>.

Once that is done, all the end user has to do is enter his absences as "away" appointments or whole day events. The OOFAutomation script will switch the OOF Assistant for him completely automatically. Administration is supported with the extensive logging into a specified file (see Installation below).


Installation is done by copying the two scripts into a folder reachable by the OOFAutomation server. This could be any Desktop PC or server that has either Outlook or Exchange Server installed. I haven't checked whether installation of a separately available CDO library would also be sufficient, but judging from Microsoft's statements on the download page, it ought to be.

After copying the script to the target folder, create a scheduled task on the OOFAutomation server that starts the script, e.g. every 30 minutes. The account that the task is run under needs to have administrative rights in Exchange or at least access rights to all end users' MAPI stores. Before activating the task, however, you have to configure the two scripts:


'TO CONFIGURE: Change "ServerName" to the name of your Exchange Server
Const sServerName = "OEBFASRV02"

'TO CONFIGURE: Change "MailboxName" to the name 
'of an administrative mailbox on the server specified above
Dim sProfileInfo    ' the MAPI logon profile
sProfileInfo = sServerName & vbLf & "Administrator"

'TO CONFIGURE: Change placeholders and 
'infixes to reflect your used languages 
'(2 at most, if more are needed then change the code yourself...)
Const placeHolderLang1 = "<Datum>"
Const placeHolderLang2 = "<Date>"
Const infixFrom1 = "von "
Const infixFrom2 = "from "
Const infixTo1 = " bis "
Const infixTo2 = " to "
Const infixOn1 = "am "
Const infixOn2 = "on "

'TO CONFIGURE: Send Mails to these people in case of error.
Const ErrMailDistributionList = "rkapl"


Log.vbs is a separately usable, simple Logger class. It can be used in other scripts as follows:

Set WshShell = WScript.CreateObject("WScript.Shell")
ExecuteGlobal CreateObject(_
    "Scripting.FileSystemObject").OpenTextFile("Log.vbs", 1).ReadAll

' PathToLogFolder.. (default = defaultLogPath in Log.vbs)
' NameOfLogFile.. (default = scriptname)
' maxLevelToBeLogged.. 0 = ERROR, _
' 1 = WARN, 2 = INFO, 3 = DEBUG (default)
' CommaSeparatedErrMailDistributionListString... 
' e.g. "admin1, admin2, admin3" (default = defaultMailRecipients in Log.vbs)
' ErrMailSender.. (default = defaultMailSender in Log.vbs)
' ErrMailSubject.. (default = defaultMailSubject in Log.vbs)
Set theLogger = new_Logger(Array(PathToLogFolder,NameOfLogFile,_
    maxLevelToBeLogged,CommaSeparatedErrMailDistributionListString, _

theLogger.LogInfo "Info Message"
theLogger.LogWarn "Warning Message"
theLogger.LogError "Error Message"
theLogger.LogStream (WshShell.Exec object) 
'logs stderr output of Exec object as 
'LogError messages, all other are logged as LogInfo
theLogger.LogFatal "Fatal Message (stops the script)"

However, it also needs to be configured before use:

'TO CONFIGURE: Send Mails to these default 
'people in case of error (if not set by using script).
Const defaultMailRecipients = "rkapl,any,other,person"
'TO CONFIGURE: The default sender of the error mails
Const defaultMailSender = "Administrator"
'TO CONFIGURE: The default subject of error mails
Const defaultMailSubject = "Process Error"
'TO CONFIGURE: The file, where internal errors are logged
Const internalLogFile = _
'TO CONFIGURE: The folder, where log files are being put
Const defaultLogPath = "\\path\to\your\Logs"

Finally, activate the task and test by entering the configured placeholder(s) in your OOFMessage text. Enter an "away" appointment that starts before now -1 minute and ends after now +1 minute.

Points of Interest

Of course, lots of the concepts used were taken from CDOLive.


  • 03/07/2007: Version 1.0: CodeProject article posted
  • 03/10/2007: Version 1.1: Bugfix for updating the OOF Message from Outlook. This is now possible as long as "I'm currently in the office" is selected and there is at least one of the placeholders (e.g. <Datum>) contained in the message.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
Austria Austria
No Biography provided

Comments and Discussions

QuestionHelp! :-( Pin
Member 1078109828-Apr-14 7:36
memberMember 1078109828-Apr-14 7:36 
GeneralError configuring this Out of Office automation Pin
Terence Tengker19-Mar-09 1:20
memberTerence Tengker19-Mar-09 1:20 
QuestionWhere to run this? Pin
fakeidname4-Oct-07 11:22
memberfakeidname4-Oct-07 11:22 
AnswerRe: Where to run this? Pin
rkapl4-Oct-07 12:41
memberrkapl4-Oct-07 12:41 
QuestionGet an error Pin
hkgartner6-Sep-07 4:45
memberhkgartner6-Sep-07 4:45 
AnswerRe: Get an error Pin
rkapl7-Sep-07 9:29
memberrkapl7-Sep-07 9:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 4 Jul 2007


9 bookmarked