none
AppointmentItem.BeforeDelete does not fire 2nd time onwards in own calendar, and does not fire at all for delegate calendars RRS feed

  • Question

  • Hello friends,

    I am facing a problem with Outlook 2010 AppointmentItem.BeforeDelete event. It just fires once after I select an appointment and click Cancel Meeting in explorer window. But when I again try to Cancel same Meeting it does not fire BeforeDelete event.

    I observed that it works fine when you debug the code, but when you run application in non-debug mode then it does not fire BeforeDelete 2nd time onwards.

    I also observed that it works fine when you select item first time and cancel meeting, then if you de-select and again select that item and cancel meeting.

    This BeforeDelete does not fire at all for delegate calendar meetings.

    Does anybody know answer to this? Please let me know.

    Thanks.


    sureshh...





    • Moved by Naomi N Monday, March 18, 2013 4:23 AM Perhaps better answer here
    • Edited by sureshh Monday, March 18, 2013 3:37 PM
    Friday, March 15, 2013 3:19 AM

All replies

  • I also checked this thread, but look like it is talking about recuring meetings. But I am facing same problem with non-recurring meeting.

     http://social.msdn.microsoft.com/Forums/en-US/olbasics/thread/305da375-d8bb-434e-a4c5-bebd38175f14

    sureshh...

    Friday, March 15, 2013 3:21 AM
  • How do you set up the event sink? Please show your code. 

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Monday, March 18, 2013 2:53 PM
  • Hi Dmitry,
    Please find my code snippet below:

    using System;
    using Microsoft.Office.Interop.Outlook;
    public class ExplorerWrapper : IDisposable
    {
        private Explorer _explorer;
        private AppointmentItem _currentSelectionAppointment { get; set; }
        public ExplorerWrapper(Explorer explorer)
        {
            try
            {
                _explorer = explorer;
                _currentSelectionAppointment = GetAppointmentItem();
                _explorer.SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(_explorer_SelectionChange);
            }
            catch {}
        }
        void _explorer_SelectionChange()
        {
            try
            {
                if (_explorer == null) return;
                try
                {
                    if (_currentSelectionAppointment != null)
                    {
                        //Note: Unhook previously hooked event here with previously selected item 
                        _currentSelectionAppointment.BeforeDelete -=
                            new ItemEvents_10_BeforeDeleteEventHandler(_currentSelectionAppointment_BeforeDelete);
                    }
                }
                catch {}
                _currentSelectionAppointment = GetAppointmentItem();
                if (_currentSelectionAppointment != null)
                {
                    //Note: Hook required events
                    _currentSelectionAppointment.BeforeDelete +=
                        new ItemEvents_10_BeforeDeleteEventHandler(_currentSelectionAppointment_BeforeDelete);
                }
            }
            catch{}
        }
        void _currentSelectionAppointment_BeforeDelete(object Item, ref bool Cancel)
        {
            //deletion logic
        }
        public object GetOutlookItem()
        {
            try
            {
                //OutlookApplication is a valid Outlook Application object
                if (OutlookApplication.ActiveExplorer() == null ||
                    OutlookApplication.ActiveExplorer().Selection == null ||
                    OutlookApplication.ActiveExplorer().Selection.Count == 0) return null;
                return OutlookApplication.ActiveExplorer().Selection[1];
            }
            catch {}
            return null;
        }
        private AppointmentItem GetAppointmentItem()
        {
            AppointmentItem apptItem = null;
            object item = GetOutlookItem();
            if (item == null) return null;
            if (item is AppointmentItem)
            {
                apptItem = (AppointmentItem)item;
            }
            return apptItem;
        }
        public void Dispose()
        {
            if (_explorer != null)
            {
                _explorer.SelectionChange -= new ExplorerEvents_10_SelectionChangeEventHandler(_explorer_SelectionChange);
            }
            _explorer = null;
            if (_currentSelectionAppointment != null)
            {
                _currentSelectionAppointment.BeforeDelete -=
                    new ItemEvents_10_BeforeDeleteEventHandler(_currentSelectionAppointment_BeforeDelete);
            }
            _currentSelectionAppointment = null;
        }
    }



    Thanks,
    Suresh


    sureshh...

    Monday, March 18, 2013 3:22 PM
  • Also please note that "This BeforeDelete does not fire at all for delegate calendar meetings.", any idea why?

    sureshh...

    Monday, March 18, 2013 3:35 PM
  • Hi Dmitry,

    To update you on this, I quickly tested the above pasted code, and found that it works fine for own calendar. There is something wrong in my complete code because of which BeforeDelete is not getting fired 2nd time onwards unless we deselect and select meeting in own calendar. I need to look into my code to figure out that.

    I confirmed that the same code does not work for delegate calendar. Do you have any idea why its no working?
    Please advise.

    Thanks,
    Suresh


    sureshh...

    Monday, March 18, 2013 3:48 PM
  • Is the delegate store cached?

    Do you see the event in OutlookSpy? Select the item, click Item button on the OutlookSpy toolbar, go to the Event tab. Delete the appointment. Do you see the event in the Log box at the bottom of the Events tab?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, March 20, 2013 1:22 PM
  • Hi Dmitry,

    Yes I do not see any events when I try cancel meeting on delegate's calendar meeting item, but I see following events when I try Cancel Meeting on own calendar's meeting item:

    BeforeDelete (IDispatch, false)
    PropertyChange (MeetingStatus)
    PropertyChange (BusyStatus)
    PropertyChange (NetMeetingAutoStart)
    PropertyChange (ReminderSet)

    Do you see any issue with this? Why is it not triggering those events for delegate calendat items?
    Please advise.

    Thanks,
    Suresh


    sureshh...


    • Edited by sureshh Wednesday, March 20, 2013 4:15 PM
    Wednesday, March 20, 2013 4:09 PM
  • Btw I do see below event triggered properly when I double click, open delegate calendar item and then click Cancel Meeting from inspector window

    Open (false)
    BeforeDelete (IDispatch, false)
    PropertyChange (MeetingStatus)
    PropertyChange (BusyStatus)
    PropertyChange (NetMeetingAutoStart)
    PropertyChange (ReminderSet)

    Do you know why it's not working in explorer view?
    • Edited by sureshh Wednesday, March 20, 2013 4:14 PM updates
    Wednesday, March 20, 2013 4:11 PM
  • I don't know, sorry.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Friday, March 22, 2013 5:52 AM
  • Anybody else has any idea about this issue? Is it a known issue? Please advise.

    sureshh...

    Tuesday, March 26, 2013 9:33 PM
  • I think your only option is to open a support case with MS (easy if you have MSDN subscription).

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Friday, March 29, 2013 2:48 PM