1

The below snippet, checks whether OOO is off. If it's turned off it will enable the OOO.

foreach (Microsoft.Office.Interop.Outlook.Store store in outlookNameSpace.Stores)

{

if (store.ExchangeStoreType==    Microsoft.Office.Interop.Outlook.OlExchangeStoreType.olPrimaryExchangeMailbox)
 {

     bool OOOStatus = store.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B");


     if (OOOStatus == false)
     {

     store.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B", true); // false to turn off OOF


                        const string DefaultOOFMessageInternal = "Hi,\n\nThanks for writing. I am OOO today ! \nThank You";

                        Outlook.StorageItem InternalOOFMessage;
                        InternalOOFMessage = inbox.GetStorage("IPM.Note.Rules.OofTemplate.Microsoft", Outlook.OlStorageIdentifierType.olIdentifyByMessageClass);
                        InternalOOFMessage.Body = DefaultOOFMessageInternal;

                        InternalOOFMessage.Save();

                        Outlook.StorageItem ExternalOOFMessage;
                        ExternalOOFMessage = inbox.GetStorage("IPM.Note.Rules.ExternalOofTemplate.Microsoft", Outlook.OlStorageIdentifierType.olIdentifyByMessageClass);

                        ExternalOOFMessage.Body = DefaultOOFMessageInternal;
                        ExternalOOFMessage.Save();




                    }

                }
            }

Is there any possibility to set the duration i.e., FROM and TO Date of an OOO by using the above method?

4

1 回答 1

0

只能使用 EWS API 设置范围。或使用Redemption及其RDOOutOfOfficeAssistant对象(如果可用,则在内部使用 EWS)。

于 2013-10-18T17:47:23.907 回答