5,661,954 members and growing! (15,266 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft Exchange » General     Intermediate

OOF Automation

By rkapl

Automated Setting of the Out of Office Assistant
VBScript, Windows, Visual Studio, Dev

Posted: 4 Jul 2007
Updated: 5 Oct 2007
Views: 10,633
Bookmarked: 6 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
2 votes for this Article.
Popularity: 1.38 Rating: 4.60 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 50.0%
3
0 votes, 0.0%
4
1 vote, 50.0%
5

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



Occupation: Software Developer (Senior)
Company: Austrian Federal Financing Agency
Location: Austria Austria

Other popular Microsoft Exchange articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
QuestionWhere to run this?memberfakeidname12:22 4 Oct '07  
AnswerRe: Where to run this?memberrkapl13:41 4 Oct '07  
QuestionGet an errormemberhkgartner5:45 6 Sep '07  
AnswerRe: Get an errormemberrkapl10:29 7 Sep '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Oct 2007
Editor: Deeksha Shenoy
Copyright 2007 by rkapl
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project