Exemple #1
0
        /// <summary>
        /// Метод ,отображающий Parent задачи ,если он есть.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonShowParent_Click(object sender, EventArgs e)
        {
            //срабатывает когда текущий контрол ,какая -нибудь таска
            if (Globals.ThisAddIn.selObject is Outlook.TaskItem)
            {
                Outlook.TaskItem taskItem =
                    (Globals.ThisAddIn.selObject as Outlook.TaskItem);
                try
                {
                    //проверяем есть ли у таски родитель
                    if (taskItem.UserProperties["Parent"] != null)
                    {
                        Outlook.NameSpace ns = Globals.ThisAddIn.Application.Session;

                        Outlook.TaskItem theitem = (Outlook.TaskItem)ns.GetItemFromID(taskItem.UserProperties["Parent"].Value.ToString());
                        //получаем текущий испектор таски
                        Outlook.Inspector inspector = theitem.GetInspector;
                        if (inspector != null)
                        {
                            inspector.Display();
                            Marshal.ReleaseComObject(inspector);
                            inspector = null;
                        }
                        Marshal.ReleaseComObject(theitem); theitem = null;
                        Marshal.ReleaseComObject(ns); ns           = null;
                    }
                    else
                    {
                        MessageBox.Show("Parent отсутсвует или удален");
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Parent отсутсвует или удален");
                }
            }
        }