By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

StoresEvents_12_Event.StoreAdd Event not firing when using Data File Management menu

P: n/a
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:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml.Linq;
  6. using Outlook = Microsoft.Office.Interop.Outlook;
  7. using Office = Microsoft.Office.Core;
  8. using System.Windows.Forms;
  9.  
  10. namespace StoreTesting
  11. {
  12.     public partial class ThisAddIn
  13.     {
  14.         Outlook.Application olApp = new Outlook.ApplicationClass();
  15.  
  16.         Outlook.Stores stores;
  17.         Outlook.Store store;
  18.  
  19.         private void ThisAddIn_Startup(object sender, System.EventArgs e)
  20.         {
  21.             stores = olApp.Session.Stores;
  22.             stores.StoreAdd += new Outlook.StoresEvents_12_StoreAddEventHandler(stores_StoreAdd);
  23.             stores.BeforeStoreRemove += new Outlook.StoresEvents_12_BeforeStoreRemoveEventHandler(stores_BeforeStoreRemove);
  24.         }
  25.  
  26.         void stores_BeforeStoreRemove(Outlook.Store Store, ref bool Cancel)
  27.         {
  28.             MessageBox.Show("store removed");
  29.         }
  30.  
  31.         void stores_StoreAdd(Outlook.Store Store)
  32.         {
  33.             MessageBox.Show("store added");
  34.         }
  35.  
  36.  
  37.         private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
  38.         {
  39.         }
  40.  
  41.         #region VSTO generated code
  42.  
  43.         /// <summary>
  44.         /// Required method for Designer support - do not modify
  45.         /// the contents of this method with the code editor.
  46.         /// </summary>
  47.         private void InternalStartup()
  48.         {
  49.             this.Startup += new System.EventHandler(ThisAddIn_Startup);
  50.             this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
  51.         }
  52.  
  53.         #endregion
  54.     }
  55. }
  56.  
Any help would be greatly appreciated.

Thanks,
Larry
Oct 15 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.