/// <summary>
        /// Gets a list of recipients email addresses, and when exception is present will not be included
        /// </summary>
        /// <param name="rcpts">Recipients</param>
        /// <param name="exception">Email address exception</param>
        /// <returns>List of emails</returns>
        public static List <string> GetRecipentsEmailAddresses(Outlook.Recipients rcpts, string exception)
        {
            List <string> results = new List <string>();

            foreach (Outlook.Recipient rcpt in rcpts)
            {
                string smtpAddress = OutlookHelper.GetEmailAddress(rcpt);
                if (smtpAddress != exception && !results.Contains(smtpAddress))
                {
                    results.Add(smtpAddress);
                }
            }
            return(results);
        }
 /// <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();
            }
        }