/// <summary>
 /// Allows to mark the selected task as completed (clear task flag for regular items)
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void mnuItemMarkComplete_Click(object sender, EventArgs e)
 {
     if (this.lstTasks.SelectedIndices.Count != 0)
     {
         OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem;
         if (task != null && !task.Completed) // Attempting to complete an already completed task throws an exception
         {
             if (MessageBox.Show("Are you sure you want to complete this task?", "Mark task as completed/Clear task flag", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 if (task.OriginalItem is Outlook.MailItem)
                 {
                     Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem;
                     mail.ClearTaskFlag();
                 }
                 else if (task.OriginalItem is Outlook.ContactItem)
                 {
                     Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem;
                     contact.ClearTaskFlag();
                 }
                 else if (task.OriginalItem is Outlook.TaskItem)
                 {
                     Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem;
                     t.MarkComplete();
                 }
                 else
                 {
                     // Do nothing
                 }
             }
             // At the end, synchronously "refresh" tasks in case they have changed
             this.RetrieveTasks();
         }
     }
 }