Click here to Skip to main content
Click here to Skip to main content

OOF Automation

, 5 Oct 2007
Rate this:
Please Sign up or sign in to vote.
Automated Setting of the Out of Office Assistant

Introduction

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

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:

OOFAutomation.vbs

'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

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, _
    ErrMailSender,ErrMailSubject))

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,mkovacs,gnebenfuehr,mhoessl,gschrenk"
'TO CONFIGURE: The default sender of the error mails
Const defaultMailSender = "Administrator@oebfa.co.at"
'TO CONFIGURE: The default subject of error mails
Const defaultMailSubject = "Process Error"
'TO CONFIGURE: The file, where internal errors are logged
Const internalLogFile = _
    "\\oebfasrv01\marktdaten\Logs\Log.vbs.internalErrs.log"
'TO CONFIGURE: The folder, where log files are being put
Const defaultLogPath = "\\oebfasrv01\marktdaten\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.

History

  • 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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

rkapl
Software Developer (Senior) Austrian Federal Financing Agency
Austria Austria
No Biography provided

Comments and Discussions

 
QuestionHelp! :-( PinmemberMember 1078109828-Apr-14 7:36 
GeneralError configuring this Out of Office automation PinmemberTerence Tengker19-Mar-09 1:20 
QuestionWhere to run this? Pinmemberfakeidname4-Oct-07 11:22 
AnswerRe: Where to run this? Pinmemberrkapl4-Oct-07 12:41 
QuestionGet an error Pinmemberhkgartner6-Sep-07 4:45 
AnswerRe: Get an error Pinmemberrkapl7-Sep-07 9:29 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 5 Oct 2007
Article Copyright 2007 by rkapl
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid