macro to make Outlook prompt me on open/close to turn Out of Office off/on

3

0

I would like to add a macro to Outlook 2007 that asks me when I shut it down if I want to turn the Out of Office Assistant on, and then asks me when I open Outlook if I want to turn Out of Office Assistant off. I've found instructions for creating the prompt at close (at Outlook 2010: How to turn Out of Office on automatically when Outlook is closed? and http://itknowledgeexchange.techtarget.com/itanswers/automating-out-of-office/) but I don't know how to write a macro for the prompt at open.

zomigi

Posted 2012-02-01T20:05:46.100

Reputation: 31

Answers

1

See here http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/A_3487-Automating-Out-of-Office-in-Outlook.html

Private Sub Application_Quit()
    OutOfOffice True
End Sub

This is the part you are interested in.

Private Sub Application_Startup()
    OutOfOffice False
End Sub

Sub OutOfOffice(bolState As Boolean)
Const PR_OOF_STATE = "http://schemas.microsoft.com/mapi/proptag/0x661D000B"
Dim olkIS As Outlook.Store, olkPA As Outlook.PropertyAccessor
For Each olkIS In Session.Stores
    If olkIS.ExchangeStoreType = olPrimaryExchangeMailbox Then
        Set olkPA = olkIS.PropertyAccessor
        olkPA.SetProperty PR_OOF_STATE, bolState
    End If
Next
Set olkIS = Nothing
Set olkPA = Nothing
End Sub 

There is a note "not tested the code with Outlook 2010."

As well " CDO (Collaboration Data Objects) must be installed on the computer. If you discover that CDO is not installed, then you can download it from this Microsoft page."

http://www.microsoft.com/downloads/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&displaylang=en

niton

Posted 2012-02-01T20:05:46.100

Reputation: 1 724