private void UnregisterEvents()
        {
            try
            {
                Log.Info("ThisAddIn.UnregisterEvents: Removing context menu display event handler");
                this.Application.ItemContextMenuDisplay -= new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.UnregisterEvents", ex);
            }
            try
            {
                Log.Info("ThisAddIn.UnregisterEvents: Removing archive button click event handler");
                this.btnArchive.Click -= new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click);
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.UnregisterEvents", ex);
            }

            try
            {
                Log.Info("ThisAddIn.UnregisterEvents: Removing new mail event handler");

                Outlook.ApplicationEvents_11_NewMailExEventHandler handler = new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);

                if (handler != null)
                {
                    this.objExplorer.Application.NewMailEx -= handler;
                }
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.UnregisterEvents", ex);
            }

            try
            {
                Log.Info("ThisAddIn.UnregisterEvents: Removing archive item send event handler");
                this.objExplorer.Application.ItemSend -= new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.UnregisterEvents", ex);
            }

            DisposeOf(appointmentSynchroniser);
            DisposeOf(contactSynchroniser);
            DisposeOf(taskSynchroniser);
        }
Example #2
0
        private void UnregisterEvents()
        {
            const string methodName = "ThisAddIn.UnregisterEvents";

            try
            {
                Log.Info(catalogue.GetString("{0}: Removing context menu display event handler", methodName));
                this.Application.ItemContextMenuDisplay -=
                    new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
            }
            catch (Exception ex)
            {
                log.Error(methodName, ex);
            }

            UnregisterButtonClickHandler(this.btnArchive, this.cbtnArchive_Click);
            UnregisterButtonClickHandler(this.btnSettings, this.cbtnSettings_Click);

            try
            {
                Log.Info(catalogue.GetString("{0}: Removing new mail event handler", methodName));

                Outlook.ApplicationEvents_11_NewMailExEventHandler handler =
                    new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);

                if (handler != null)
                {
                    this.objExplorer.Application.NewMailEx -= handler;
                }
            }
            catch (Exception ex)
            {
                log.Error(methodName, ex);
            }

            try
            {
                Log.Info(catalogue.GetString("{0}: Removing archive item send event handler", methodName));
                this.objExplorer.Application.ItemSend -= new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);
            }
            catch (Exception ex)
            {
                log.Error(methodName, ex);
            }
        }