4
Is it possible to make Outlook 2010 turn on the "Automatic Replies" feature when I close the application? I like to turn on "Out of Office" at the end of the day but in a hurry it's easily forgotten.
4
Is it possible to make Outlook 2010 turn on the "Automatic Replies" feature when I close the application? I like to turn on "Out of Office" at the end of the day but in a hurry it's easily forgotten.
5
I REALLY tried to make this work for you, but I learned that Outlook 2010 no longer supports CDO 1.2.1, and not being a programmer, I did not have the deep knowledge to code it another way. Although unsupported and not recommended by Microsoft (why do they mention it then??), it is possible to install CDO if you have Outlook 2007, before you upgrade to Outlook 2010.
http://support.microsoft.com/kb/2028411
I am going to post how to do this in Outlook 2003/2007 in case anyone happens upon this. I just tested this. I will also post the other steps for Outlook 2010 ASSUMING YOU CAN FIX THE CODE.
For Outlook 2007 only, you must install CDO or the code will fail: http://www.microsoft.com/downloads/en/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&displaylang=en
Assuming your company's group policy does not override this, change the security in Tools
→ Macros
→ Security
to No Security Check for macros
.
Go to Tools
→ Macros
→ Visual Basic Editor
.
Click on the Visual Basic icon, and hit F2 to open the objects browser.
In the new project in the left pane expand it until you see ThisOutlookSession
and double-click it.
Cut and paste the following code into the code window that just opened and save it:
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
Close and open Outlook.
It will give you a message about macros. Enable them.
If you can fix the code, here are the steps for Outlook 2010. I include them because the locations of many items have changed, and could be hard to find. In the current code, I also point out the step that fails.
Assuming your company's group policy does not override this, change the security in File
→ Options
→ Trust Center
→ Trust Center Settings
→ Macro Settings
to Enable all macros
.
Start by enabling the Developer
tab in File
→ Options
→ Customize Ribbon
, check Developer
in the right column.
Click on the Visual Basic icon, and hit F2 to open the objects browser.
Go to Classes
(left column) → ThisOutlookSession
and double-click it.
Cut and paste the following code into the code window that just opened and save it:
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") THIS IS THE STEP THAT FAILS
objMAPISession.Logon , , True, False
objMAPISession.OutOfOffice = True
objMAPISession.Logoff
End If
Set objMAPISession = Nothing
End Sub
Close and open Outlook.
Go back to the Developer
tab → Macros
icon. It will give you a message about macros. Enable them.
4
Another way around this (as I don't believe you can change the date/time parameters for the Out Of Office Assistant via VBA) is to perform the following steps:
Application_Start
and Application_Quit
to enable/disable the rule:Option Explicit Private Sub Application_Quit() SetRuleEnabled True End Sub Private Sub Application_Startup() SetRuleEnabled False End Sub Private Sub SetRuleEnabled(ByVal bEnable As Boolean) Dim oSession As Outlook.NameSpace Dim oRule As Outlook.Rule Dim oRules As Outlook.Rules Dim oPA As Outlook.PropertyAccessor Set oSession = Application.Session Set oRules = oSession.DefaultStore.GetRules() Set oPA = oSession.DefaultStore.PropertyAccessor '*** If the Out-Of-Office is already on (eg. holidays, sick leave etc.) '*** then it might be best to force this rule permanently off If oPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B") Then bEnable = False End If For Each oRule In oRules If oRule.Name = "HomeTime" Then oRule.Enabled = bEnable oRules.Save Exit For End If Next End Sub
1 issue to keep in mind is that this response will fire each time for each subsequent reply. Unlike the Out-Of-Office assistant that ignores subsequent replies.
PS. With the Out of Office check in the VBA above, you will need reference to the CDO library. If you don't want to check for Out-Of-Office being on, then you won't need CDO.
2
Awesome! Thanks KCotreau. I got it working on MS Outlook 2003. Below is the code snippet - I just wrapped it wihtin the pre and code to not have it all in a single line.
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
This is nice, but is it possible to have it actually run at a future day/time? That will be a real plus, because if you have a vacation planned and forget to turn OOF, it will automatically kick in without human intervention...eh?
1
It appears Outlook generates an Application_Quit event when closing that could be hooked to set the OOF. Pressing Alt-F11 in Outlook brings up the macro editor. Start poking around there.