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?