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?
 
Thread starter Similar threads Forum Replies Date
R Prompt asking the user to send email to folder as *.msg file Outlook VBA and Custom Forms 1
R Make Enter Network Password Prompt Go Away Automatically Using Outlook 0
K VBA to prompt and send a CC Outlook VBA and Custom Forms 6
K VBA - Prompt for reminder date time Outlook VBA and Custom Forms 7
S Have Rule or Quick Step PROMPT for custom FLAG Due/Reminder date Outlook VBA and Custom Forms 3
P Constant Username Password Prompt Using Outlook 2
A Prompt on exit to empty deleted items folder "for all accounts" does not work? Using Outlook 6
C Is there a way to prompt a user before deleting an item? BCM (Business Contact Manager) 4
S Prompt to add for text to existing subject line before sending. Using Outlook 9
S Trying to have a prompt to ask for text to be added to subject before sending. Using Outlook 3
N Prompt for password when sending an email Exchange Server Administration 1
O How to turn off the prompt to permanently delete messages upon exiting? Using Outlook 2
G Outlook keep prompt for log in credential Using Outlook 1
J Deactivate MS Outlook 2007 prompt to make it the default email client Using Outlook 1
O Outlook 2007 SP2 Prompt for Password Exchange Server Administration 3
R Does not prompt for saving or opening attachments when downloading attachment in Outlook 2007. Using Outlook 3
S Continuous password and username prompt in outlook 2007 Using Outlook 1
E Enter Network Password prompt does not accept my password Using Outlook 4
I Prompt before sending contacts to Deleted Items folder Using Outlook 7
B Password prompt for the pst files Using Outlook 9
O OWA 2003 prompt to re-auntenticate when opening up office attachments Using Outlook 10
L outlook 2007 login prompt from old exchange host Using Outlook 3
B outlook 2007 password prompt keeps popping up Using Outlook 1
M Outlook 2007 and Outlook 2010 continues to prompt user for their password Using Outlook 7
E Users get login prompt in Outlook 2007 when accessing Exchange Server 2007 Using Outlook 2
D Credentials Prompt Exchange Server Administration 1
L Strange macro prompt Using Outlook 1
C outlook clients prompt for a password each time it open Exchange Server Administration 2
S exchange 2010 e-mail user password expiration prompt Exchange Server Administration 8
S After installing 3rd party Certificate for IIS , prompt warning for mapi clients the name on security certificate is invalid , Exchange Server Administration 3
S cross post please read: Exchange Account password prompt in Outlook 2010 Using Outlook 2
S How to add multiple exchange accounts without password / credential prompt? Using Outlook 5
T Outlook 2010 Setting to Prompt 'Send before Exiting'__ Using Outlook 2
J Enable prompt to save/open attachment Using Outlook 1
C Reboot a CAS array member causes Outlook 2010 clients to prompt for credentials. Using Outlook 5
O Password Prompt in Outlook 2003 Using Outlook 4
M Email Prompt Outlook VBA and Custom Forms 1
T Prompt for email account Outlook VBA and Custom Forms 1
P Outlook security prompt after installing Add-in Outlook VBA and Custom Forms 3
Q Otlk 2007 does not block when in "always prompt for..." mode Outlook VBA and Custom Forms 2
Q sending mail when Otlook in 'always prompt for user name and passw Outlook VBA and Custom Forms 4
J Outlook 2007 Clients Prompt For Password When Opening Using Outlook 21
N Which Button Was Clicked on the Ribbonbar Menu Outlook VBA and Custom Forms 2
E Can't accept or decline task (no button appears) Using Outlook 4
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
C iCloud Setting missing Outlook tab and Outlook missing the iCloud refresh button Using Outlook 4
witzker Outlook 2010 Insert Date & Time at the button of an OL contactform in red Using Outlook 2
S How to set up button in ribbon for individual Quick Steps Using Outlook 1
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
J Command Button to stamp a date and time in a textbox in Outlook 2016 Outlook VBA and Custom Forms 3
Similar threads


















































Top