/// <summary>
 /// Creates a new mail item to reply all recipients of an appointment (except the current user)
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void mnuItemReplyAllEmail_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)
         {
             Outlook.MailItem mail           = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
             string           curUserAddress = OutlookHelper.GetEmailAddress(Globals.ThisAddIn.Application.Session.CurrentUser);
             foreach (Outlook.Recipient rcpt in appt.Recipients)
             {
                 string smtpAddress = OutlookHelper.GetEmailAddress(rcpt);
                 if (curUserAddress != smtpAddress)
                 {
                     mail.Recipients.Add(smtpAddress);
                 }
             }
             mail.Body    = Environment.NewLine + Environment.NewLine + appt.Body;
             mail.Subject = Constants.SubjectRE + ": " + appt.Subject;
             mail.Display();
         }
     }
 }
        /// <summary>
        /// When the user "drops" one or more email items into the calendar
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">DragEventArgs</param>
        private void lblCtrl_DragDrop(object sender, DragEventArgs e)
        {
            Label lblDay = sender as Label;

            if (sender != null)
            {
                Outlook.Explorer mailExpl       = Globals.ThisAddIn.Application.ActiveExplorer();
                List <string>    attendees      = new List <string>();
                string           curUserAddress = OutlookHelper.GetEmailAddress(Globals.ThisAddIn.Application.Session.CurrentUser);
                string           body           = String.Empty;
                string           subject        = String.Empty;
                foreach (object obj in mailExpl.Selection)
                {
                    Outlook.MailItem mail = obj as Outlook.MailItem;
                    if (mail != null)
                    {
                        subject = mail.Subject;
                        body    = mail.Body;
                        if (mail.SenderEmailAddress != curUserAddress && !attendees.Contains(mail.SenderEmailAddress))
                        {
                            attendees.Add(mail.SenderEmailAddress);
                        }
                        attendees.AddRange(OutlookHelper.GetRecipentsEmailAddresses(mail.Recipients, curUserAddress));
                    }
                    else // It's not an email, let's see if it's a meeting instead
                    {
                        Outlook.MeetingItem meeting = obj as Outlook.MeetingItem;
                        if (meeting != null)
                        {
                            subject = meeting.Subject;
                            body    = meeting.Body;
                            if (meeting.SenderEmailAddress != curUserAddress && !attendees.Contains(meeting.SenderEmailAddress))
                            {
                                attendees.Add(meeting.SenderEmailAddress);
                            }
                            attendees.AddRange(OutlookHelper.GetRecipentsEmailAddresses(meeting.Recipients, curUserAddress));
                        }
                        else // It wasn't a meeting either, let's try with an appointment
                        {
                            Outlook.AppointmentItem appointment = obj as Outlook.AppointmentItem;
                            if (appointment != null)
                            {
                                subject = appointment.Subject;
                                body    = appointment.Body;
                                if (appointment.Organizer != curUserAddress && !attendees.Contains(appointment.Organizer))
                                {
                                    attendees.Add(appointment.Organizer);
                                }
                                attendees.AddRange(OutlookHelper.GetRecipentsEmailAddresses(appointment.Recipients, curUserAddress));
                            }
                        }
                    }
                }
                Outlook.AppointmentItem appt = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;
                attendees.ForEach(a => appt.Recipients.Add(a));
                appt.Body    = Environment.NewLine + Environment.NewLine + body;
                appt.Subject = subject;
                DateTime day = (DateTime)lblDay.Tag;
                DateTime now = DateTime.Now;
                appt.Start = OutlookHelper.RoundUp(new DateTime(day.Year, day.Month, day.Day, now.Hour, now.Minute, now.Second), TimeSpan.FromMinutes(15));
                appt.Display();
            }
        }