/// <summary>
 /// Open the appointment, having in mind it might be a recurring event
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void lstAppointments_DoubleClick(object sender, EventArgs e)
 {
     if (this.lstAppointments.SelectedIndices.Count != 0)
     {
         Outlook.AppointmentItem appt = this.lstAppointments.SelectedItems[0].Tag as Outlook.AppointmentItem;
         if (appt != null)
         {
             if (appt.IsRecurring)
             {
                 FormRecurringOpen f = new FormRecurringOpen();
                 f.Title   = "Open Recurring Item";
                 f.Message = "This is one appointment in a series. What do you want to open?";
                 if (f.ShowDialog() == DialogResult.OK)
                 {
                     if (f.OpenRecurring)
                     {
                         // Open up the master appointment in a new window
                         // If we open the current instance then there is an error: "This item is no longer valid because it has been closed"
                         // One workaround is to refresh the appointments list to get new instances...
                         Outlook.AppointmentItem masterAppt = appt.Parent; // Get the master appointment item
                         masterAppt.Display(true);                         // Will modify ALL instances
                     }
                     else
                     {
                         // Open up the appointment in a new window
                         appt.Display(true); // Modal yes/no
                     }
                 }
             }
             else
             {
                 // Open up the appointment in a new window
                 appt.Display(true); // Modal yes/no
             }
             // At the end, synchronously "refresh" appointments in case they have changed
             this.RetrieveAppointments();
         }
     }
 }
 /// <summary>
 /// Allows to delete the selected appointment (whether it's a recurring one or not)
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void mnuItemDeleteAppointment_Click(object sender, EventArgs e)
 {
     if (this.lstAppointments.SelectedIndices.Count != 0)
     {
         Outlook.AppointmentItem appt = this.lstAppointments.SelectedItems[0].Tag as Outlook.AppointmentItem;
         if (appt != null)
         {
             if (appt.IsRecurring)
             {
                 FormRecurringOpen f = new FormRecurringOpen();
                 f.Title   = "Warning: Delete Recurring Item";
                 f.Message = "This is one appointment in a series. What do you want to delete?";
                 if (f.ShowDialog() == DialogResult.OK)
                 {
                     if (f.OpenRecurring)
                     {
                         Outlook.AppointmentItem masterAppt = appt.Parent; // Get the master appointment item
                         masterAppt.Delete();                              // Will delete ALL instances
                     }
                     else
                     {
                         appt.Delete(); // Delete just this instance
                     }
                 }
             }
             else
             {
                 if (MessageBox.Show("Are you sure you want to delete this appointment?", "Delete appointment", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     appt.Delete(); // Delete just this instance
                 }
             }
             // At the end, synchronously "refresh" appointments in case they have changed
             this.RetrieveAppointments();
         }
     }
 }