Here is a source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn2
{
public partial class ThisAddIn
{
const string DefaultOOFMessageInternal = "Vielen Dank für Ihre Nachricht. Ich antworte Ihnen nach meiner Rückkehr so rasch wie möglich. Oder rufen Sie uns an, damit sich meine Stellvertretung um Sie kümmern kann.";
Outlook.Application app;
Outlook.NameSpace ns;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
app = Globals.ThisAddIn.Application;
ns = app.GetNamespace("MAPI");
bool OOFState;
Outlook.MAPIFolder Inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.PropertyAccessor pa = Inbox.PropertyAccessor;
foreach (Outlook.Store store in ns.Stores)
{
if (store.ExchangeStoreType == Outlook.OlExchangeStoreType.olPrimaryExchangeMailbox)
{
OOFState = (bool)store.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B");
}
}
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();
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
</< pre>
It is also possible to activate the OOF with this sourcecode.









