Get status of out of office and set it to false (I'm present)

Ease of Use


Version tested with


Submitted by:



Switch the out of office status to false = I'm back. If status was false, nothing happens. Out of Office assistant requires Exchange Server 


Sometimes you need to leave your computer running for some specific tasks but you are not available. When you come back after a well deserved two days week-end, you could forget to turn the out of office assistant off. This coding can be used to autochange the status from true (assistant is used) to false by using some extra coding (not provided) that uses an on time event (this event is started when you turn your assistant on at Friday). 


instructions for use


Sub test_out_of_office() 'You need a reference to cdo 1.21 library Dim oCDO As MAPI.Session Dim oStore As MAPI.InfoStore Dim oFolder As MAPI.Folder Dim strStoreID As String Dim blnOOF As Boolean Set oCDO = CreateObject("MAPI.Session") oCDO.Logon "", "", False, False 'piggy-back logon Set oFolder = oCDO.Inbox 'get default Inbox strStoreID = oFolder.StoreID 'get default InfoStore.StoreID0 Set oStore = oCDO.GetInfoStore(strStoreID) 'get store 'Next line doesn't work in 2003 'blnOOF = oStore.Fields(&H661D000B) 'get property 'This line does work. 'Get value of the out of office = on of off blnOOF = oCDO.OutOfOffice If blnOOF = False Then MsgBox "Out Of Office is off." Else MsgBox "Out of Office in on." 'Turn it off oCDO.OutOfOffice = False 'As an extra check up MsgBox "Out Of Office = " & oCDO.OutOfOffice End If End Sub

How to use:

  1. Create a new module in Outlook and paste this code
  2. Set a reference to cdo 1.21 (alt + f11 - extra - references)
  3. For Outlook 2007 - users. You need to download the cdo library and install it on the machine that you want to test this code on because this code requires a reference in the project to the Collaboration Data Objects (CDO 1.21) library. This is an optional component of Outlook 2003 and earlier versions and available as a separate download for Outlook 2007. See http://www.outlookcode.com/d/cdo.htm
  4. Download here:
  5. http://www.microsoft.com/downloads/details.aspx?FamilyID=2714320d-c997-4de1-986f-24f081725d36&displaylang=en

Test the code:

  1. Set your assistant on and run the code.

Sample File:

No Attachment 

Approved by Jacob Hilderbrand

This entry has been viewed 101 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express