用C代码在Outlook中为OOO邮件设置起始日期和截止日期
下面的代码片段检查OOO是否已关闭。如果关闭,将启用OOO用C代码在Outlook中为OOO邮件设置起始日期和截止日期,outlook,interop,add-in,Outlook,Interop,Add In,下面的代码片段检查OOO是否已关闭。如果关闭,将启用OOO foreach (Microsoft.Office.Interop.Outlook.Store store in outlookNameSpace.Stores) { if (store.ExchangeStoreType== Microsoft.Office.Interop.Outlook.OlExchangeStoreType.olPrimaryExchangeMailbox) { bool OOOStatu
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();
}
}
}
是否可以使用上述方法设置OOO的持续时间,即从和到日期?只能使用EWS API设置范围。或者,如果EWS可用,则使用其内部使用EWS的对象