Private Sub Application_Startup()
CheckOOFState
End Sub
Sub CheckOOFState()
Const PR_OOF_STATE = "http://schemas.microsoft.com/mapi/proptag/0x661D000B"
Dim olkIS As Outlook.Store, olkPA As Outlook.PropertyAccessor, bolOOF As Boolean, varChoice As Variant
For Each olkIS In Session.Stores
If olkIS.ExchangeStoreType = olPrimaryExchangeMailbox Then
Set olkPA = olkIS.PropertyAccessor
bolOOF = olkPA.GetProperty(PR_OOF_STATE)
Exit For
End If
Next
If bolOOF Then
'Edit the message as you see fit.'
varChoice = MsgBox("Out of Office is turned on. Do you want to turn it off?", vbInformation + vbYesNo + vbApplicationModal, "Out of Office Reminder")
If varChoice = vbYes Then
olkPA.SetProperty PR_OOF_STATE, False
End If
End If
Set olkIS = Nothing
Set olkPA = Nothing
End Sub
|