Prompt button to auto turn on Out of Office

qksmatt

New Member
Outlook version
Outlook 2019 64-bit
Email Account
Office 365 Exchange
Hi,

I have been working on some VBA to allow me to just click a yes button to turn on my Out of Office when I quit outlook but I can't get it to work.

I'm on Office 365.

Code is as follows:

Private Sub Application_Quit()
Dim objMAPISession As Object
Set objReminders = Nothing
If MsgBox("Would you like to turn the Out of Office Assistant on?", vbYesNo, "Activate Out of Office Assistant") = vbYes Then
Set objMAPISession = CreateObject(“MAPI.Session”)
objMAPISession.Logon , , True, False
objMAPISession.OutOfOffice = True
objMAPISession.Logoff
End If
Set objMAPISession = Nothing
End Sub


Can anyone help fix my code for me?

Thanks
 

qksmatt

New Member
Outlook version
Outlook 2019 64-bit
Email Account
Office 365 Exchange
Thank you for your reply, I am quite new to VBA and am struggling to work out how to fit that into my code. Would you be able to offer any advice?
 
Top