• Subject: Cancelling Tasks Write event removes Send button from inspector window
  • Author: Adi
  • Date: 10 May 2008
  • References:
Hi, I have created an Outlook Addin which needs to cancel the write/send event on certain modifications made in Tasks through the inspector window. So, if I create a Task in Outlook, Assign it, and Send it, only Write event is triggered (that too twice). If I cancel the event as demonstrated in the code below, Send button gets removed from the inspector window and 'Assign Task' and other buttons gets disabled. Following is the sample code written in VSTO 2005 SE: using System; using System.Windows.Forms; using Microsoft.VisualStudio.Tools.Applications.Runtime; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; namespace OutlookAddIn3 { public partial class ThisAddIn { private Outlook.Inspectors m_insps; private Outlook.TaskItem m_task; private Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler m_sendHandler; private void ThisAddIn_Startup(object sender, System.EventArgs e) { m_insps = Application.Inspectors; m_insps.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(m_insps_NewInspector); } void m_insps_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector) { #region Tasks Outlook.TaskItem task = Inspector.CurrentItem as Outlook.TaskItem; if (task != null) { m_task = task; m_task.Write += new Microsoft.Office.Interop.Outlook.ItemEvents_10_WriteEventHandler(m_task_Write); m_sendHandler = new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(ThisAddIn_Send); ((Outlook.ItemEvents_10_Event)m_task).Send += m_sendHandler; } #endregion } void ThisAddIn_Send(ref bool Cancel) { MessageBox.Show("Send"); Cancel = true; } void m_task_Write(ref bool Cancel) { MessageBox.Show("Save"); Cancel = true; } 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 } } I want that when I cancel the event, it should come back to the inspector window without any modifications done to the current state of the inspector window. Could somebody please help in this regards? Thanks,
10 May 2008Cancelling Tasks Write event removes Send button from inspector window.Adi
21 May 2008\ Re: Cancelling Tasks Write event removes Send button from inspector window.Sue Mosher [MVP-Outlook]
26 May 2008   \ Re: Cancelling Tasks Write event removes Send button from inspector window.Adi
04 Jul 2008      \ Re: Cancelling Tasks Write event removes Send button from inspecto.Wojciech Parzych
07 Jul 2008         \ Re: Cancelling Tasks Write event removes Send button from inspecto.Adi
All times are in (US) Eastern Daylight Time (GMT -4:00)