Monday 31 December 2018

automation - How to turn Out of Office on automatically when Outlook is closed?


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.



Answer



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 2003/2007




  1. 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




  2. Assuming your company's group policy does not override this, change the security in ToolsMacrosSecurity to No Security Check for macros.




  3. Go to ToolsMacrosVisual Basic Editor.




  4. Click on the Visual Basic icon, and hit F2 to open the objects browser.




  5. In the new project in the left pane expand it until you see ThisOutlookSession and double-click it.




  6. 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


  7. Close and open Outlook.




  8. It will give you a message about macros. Enable them.




For Outlook 2010


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.




  1. Assuming your company's group policy does not override this, change the security in FileOptionsTrust CenterTrust Center SettingsMacro Settings to Enable all macros.




  2. Start by enabling the Developer tab in FileOptionsCustomize Ribbon, check Developer in the right column.




  3. Click on the Visual Basic icon, and hit F2 to open the objects browser.




  4. Go to Classes (left column) → ThisOutlookSession and double-click it.




  5. 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


  6. Close and open Outlook.




  7. Go back to the Developer tab → Macros icon. It will give you a message about macros. Enable them.




No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...