I am writing an Outlook add-in that needs to fire when a PST is added/removed. I have successfully fired the event using the AddStore and RemoveStore functions, as well as when I use the "Open -> Outlook Data File" menu option. The issue is that when I go through the Data File Management screen, the event never fires.
Here is the "dummy code" I'm using outside of my main application for testing purposes:
Any help would be greatly appreciated.
Thanks,
Larry
Here is the "dummy code" I'm using outside of my main application for testing purposes:
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;
using System.Windows.Forms;
namespace StoreTesting
{
public partial class ThisAddIn
{
Outlook.Application olApp = new Outlook.ApplicationClass();
Outlook.Stores stores;
Outlook.Store store;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
stores = olApp.Session.Stores;
stores.StoreAdd += new Outlook.StoresEvents_12_StoreAddEventHandler(stores_StoreAdd);
stores.BeforeStoreRemove += new Outlook.StoresEvents_12_BeforeStoreRemoveEventHandler(stores_BeforeStoreRemove);
}
void stores_BeforeStoreRemove(Outlook.Store Store, ref bool Cancel)
{
MessageBox.Show("store removed");
}
void stores_StoreAdd(Outlook.Store Store)
{
MessageBox.Show("store added");
}
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
}
}
Thanks,
Larry