Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reoccurring Out-of-Office

Posted on 2014-03-24
6
Medium Priority
?
905 Views
Last Modified: 2014-05-03
Hello all,

This is in reference to article: http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/A_3487-Automating-Out-of-Office-in-Outlook.html

I am trying to set up Outlook to check what day of the week tomorrow would be and turn on out of office during 8am-5pm that day, if it was a specific day.

Example: Every Monday at the end of the day, Outlook would set the OOO for business hours on Tuesday - (This would be helpful for a part-timer that doesn't work on Tuesday's).

This employee's messages are vital to the business and would wouldn't want to risk them forgetting to turn it on for our customers.
0
Comment
Question by:Guy-in-Transition
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Trenton Knew
ID: 39951847
Delegate another user to that employee's mailbox so someone can fetch messages from their mailbox anytime
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 39967396
Hi, Guy-in-Transition.

I wrote the article you linked to.  The code in that article depends on CDO which is not supported under Outlook 2010 and later.  For that reason, I've created a new version that should work under outlook 2007 and later.  This version also runs from outside of Outlook, which will allow you to schedule it.  

Follow these instructions to use this solution.

1.  Open Notepad
2.  Copy the code below and paste it into Notepad
3.  Save the file.  You can name it anything you like, but the extension must be .vbs
4.  Using Windows task scheduler, create a task schedule to run at the end of the day
5.  Set the task to run the script saved in step #3.  The script takes two named parameters: State and Message.  The format of the command line will be something like this.

To turn out of office on and set a message

wscript.exe Out-of-Office.vbs /State:on /Message:"I am out of the office until tomorrow morning at 7:00am"

To turn out of office off

wscript.exe Out-of-Office.vbs /State:off

This solution has to run at a computer with Outlook installed.  It is not designed to run at the Exchange server.

'--> Define some constants
	Const olPrimaryExchangeMailbox = 0
	Const olIdentifyByMessageClass = 2
	Const olFolderInbox = 6
	Const PR_OOF_STATE = "http://schemas.microsoft.com/mapi/proptag/0x661D000B"

'--> Define some variables
	Dim strVer, olkApp, olkSes, colArg, strSta, strMsg, bolSta
	
'--> Get the arguments from the command line
	Set colArg = WScript.Arguments.Named
	strSta = colArg.Item("State")
	strMsg = colArg.Item("Message")
	Select Case LCase(strSta)
		Case "on","out","true"
			bolSta = True
		Case Else
			bolSta = False
	End Select
	If strMsg = "" Then strMsg = "Out of the office"
	
'--> Connect to Outlook
	Set olkApp = CreateObject("Outlook.Application")
	Set olkSes = olkApp.GetNamespace("MAPI")
	olkSes.Logon olkApp.DefaultProfileName
	
'--> Set the out of office state
	strVer = GetOutlookVersion()
	SetOutOfOfficeState bolSta, strMsg
	
'--> Disconnect from Outlook
	olkSes.Logoff

'--> Clean up objects
	Set olkSes = Nothing
	Set olkApp = Nothing
	
'--> Terminate the script
	WScript.Quit

Sub SetOutOfOfficeState(bolState, strMessage)
    ' Purpose: Set the state of Out of Office.'
    ' Written: 10/12/2009'
    ' Author:  David Lee'
    ' Outlook: 2007'
    Dim olkIS, olkPA, olkSto
    'On Error Resume Next
    If strVer >= "12.0" Then
        For Each olkIS In olkSes.Stores
            If olkIS.ExchangeStoreType = olPrimaryExchangeMailbox Then
            	Set olkSto = olkSes.GetDefaultFolder(olFolderInbox).GetStorage("IPM.Note.Rules.OofTemplate.Microsoft", olIdentifyByMessageClass)
            	olkSto.Body = strMessage
				olkSto.Save
                Set olkPA = olkIS.PropertyAccessor
                olkPA.SetProperty PR_OOF_STATE, bolState
            End If
        Next
    Else
        MsgBox "The SetOutOfOfficeState method is only available to Outlook 2007 and later", vbExclamation + vbOKOnly
    End If
    On Error GoTo 0
    Set olkIS = Nothing
    Set olkPA = Nothing
    Set olkSto = Nothing
End Sub

Function GetOutlookVersion()
    ' Purpose: Returns the Outlook version in the form xx.x.'
    ' Written: 6/3/2011'
    ' Author:  David Lee'
    ' Outlook: All version'
    Dim arrVersion
    arrVersion = Split(olkapp.Version, ".")
    GetOutlookVersion = arrVersion(0) & "." & arrVersion(1)
End Function

Open in new window

0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40026919
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40026920
I object.  There is enough information to confirm an answer.  All that's required is to test the code yourself to see that it works as described.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question