none
Enable or disable out of office from VBScript for Outlook RRS feed

  • Question

  • Hi,

    How to enable/disable outlook out of office from VBScript? It should also be possible to set mail body text, From and To Date/Time.

    Please help.

    Regards,

    Vinay


    • Edited by Vinay Bedre Saturday, November 30, 2013 10:23 AM
    Saturday, November 30, 2013 10:22 AM

Answers

  • If you only need to turn OOF one/off, you can read/set the PR_OOF_STATE MAPI property (DASL name http://schemas.microsoft.com/mapi/proptag/0x661D000B) using Store.PorpertyAccessor.

    OOF text is stored in a hidden message (accessible through MAPIFolder.GetStorage) with the message class of "PM.Note.Rules.OofTemplate.Microsoft".

    Note that there can be multiple message with that class, and you cannot distinguish between them using the Outlook Object Model alone. Same if that message was never created - there is no way for you to create one and associate it with the OOF rule.

    Also note that external/internal OOF replies and OOF time range can only be accessed using EWS.

    If using Redemption is an option, take a look at the RDOOutOfOfficeAssistant  object.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, November 30, 2013 3:42 PM

All replies

  • Hi Vinay,

    Do you mean VBA? Please note that VBScript and VBA are different things.

    Saturday, November 30, 2013 10:35 AM
  • Hi,

    I mean VBScript, which i can use in Internet Explorer. I actually want to automate Out of office from Windows Gadget. So if I get the script to access out of office settings from VBScript, would help me a lot.

    Regards,

    Vinay

    Saturday, November 30, 2013 10:39 AM
  • Vinay,

    First of all, please take a look at the HOWTO: Automate any application from Internet Explorer article. It describes the steps required to automate any application from Internet Explorer.

    There are two possible ways of implementing the described task:

    1. The straight and easiest one is to handle the NewMail and NewMailEx events of the Application class and reply to the incoming e-mails manually (using the Outlook Object Model). All Outlook versions are supported (except that NewMailEx was introduced in Outlook 2003).

    2. Also you can enable the auto-response feature creating a rule in Outlook (as you do in Outlook wizards). You can read more about this in the Managing Rules in the Outlook Object Model article in MSDN. Also you may be interested in the How to: Create a Rule to Move Specific E-mails to a Folder article. Be aware that only starting from Outlook 2010 the Object Model provides the Rules collection.


    Saturday, November 30, 2013 11:08 AM
  • If you only need to turn OOF one/off, you can read/set the PR_OOF_STATE MAPI property (DASL name http://schemas.microsoft.com/mapi/proptag/0x661D000B) using Store.PorpertyAccessor.

    OOF text is stored in a hidden message (accessible through MAPIFolder.GetStorage) with the message class of "PM.Note.Rules.OofTemplate.Microsoft".

    Note that there can be multiple message with that class, and you cannot distinguish between them using the Outlook Object Model alone. Same if that message was never created - there is no way for you to create one and associate it with the OOF rule.

    Also note that external/internal OOF replies and OOF time range can only be accessed using EWS.

    If using Redemption is an option, take a look at the RDOOutOfOfficeAssistant  object.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, November 30, 2013 3:42 PM
  • I have using the following code. Can anyone help me to complete?

    var theApp = new ActiveXObject("Outlook.Application");
    var objNS = theApp.GetNameSpace('MAPI');

    Please help


    Vinay Bedre

    Wednesday, December 4, 2013 11:26 AM
  • Hello Vinay,

    I have described two possible ways for implementing the required functionality in my previous post. Did you have a chance to look at the How to: Create a Rule to Move Specific E-mails to a Folder article at least? There also you can find a sample code for creating rules in Outlook.

    Wednesday, December 4, 2013 11:43 AM
  • Eugene,

    what the original poster asks is the Out-Of-Office functionality in Outlook, which is only available under Exchange (File | Automatic Replies (Out Of Office)).

    It has absolutely  nothing to do with client side rules in Outlook.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 4, 2013 1:23 PM