private void btnEmail_Click(object sender, EventArgs e)
        {
            string strCCEmail = "";

            // get the teacher´s email address..

            string strSelectedTeacher = lstTeachers.SelectedItems[0].ToString();
            string strToEmail = staffGrp.FindStaffEmail(strSelectedTeacher);

            if( strToEmail.Length == 0)
            {
                MessageBox.Show("No email for the selected teacher");
                return;
            }

            // get the copied teacher if any ( up to one for now!)

            if (lstTeachers.SelectedItems.Count > 1)
            {
                strCCEmail = staffGrp.FindStaffEmail(lstTeachers.SelectedItems[1].ToString());
            }

            // send the email..

               Emailer eMail = new Emailer( strStaffEmail, strStaffPassword);

            if (strCCEmail == "")
            {
                eMail.SendMessage(strToEmail, "", strSubject, strMessage, false);
            }
            else
            {
                eMail.SendMessage(strToEmail,strCCEmail, strSubject, strMessage, true);
            }
        }
        public void SendEmails( int nTutorCount, bool bStandardMessage, bool bCC)
        {
            // must have chosen options for a standard message..

            if (bStandardMessage && currentEvent.IsValid() == false)
            {
                MessageBox.Show("Please select all options");
                return;
            }

            ConvertChars c = new ConvertChars();
            string strSubject = "";

            // organise by tutor..

            for (int i = 0; i < nTutorCount; i++)
            {
                Tutor t = arrTutors[i];

                string strPupilNames = t.GetPupilNames();

                // start message..

                string strMessage = "Dear " + t.GetTutor() + ",";

                if (bStandardMessage == true)
                {
                    // create message..
                    strMessage += c.DoubleNL() + "Just to let you know that the following pupil" + t.GetS() + " ";
                    strMessage += (t.IsPural() ? currentEvent.GetEventDetail() : currentEvent.GetEventDetail()); // check
                    strMessage += " " + currentEvent.GetEventTime() + " today: ";
                    strMessage += strPupilNames + c.NL();
                    strMessage += "I will add this to the behaviour log." + c.DoubleNL();
                    strSubject = currentEvent.GetEventCategory();
                }
                else
                {
                    strMessage += c.DoubleNL();
                    strMessage += txtMessage.Text + c.DoubleNL();

                    strSubject = strPupilNames; // set category to pupil name..
                }

                strMessage += "Kind Regards, " + c.NL() + strStaffFirstName;

                bCC = true;

                // send each message..
                if( eMail == null)
                {
                    eMail = new Emailer(strStaffEmail,strStaffPassword);
                }

                eMail.SendMessage(t.GetTutorEmail(), t.GetYearEmail(), strSubject, strMessage, bCC);

                // update the behaviour log file..

                //  currentEvent.UpdateBehaviourLog(strStaffEmail, p); // only for preset.
            }
        }
        private void btnParents_Click(object sender, EventArgs e)
        {
            Emailer eM = new Emailer( strStaffEmail,strStaffPassword);

            // update spreadsheet for mail merge..

            // for each pupil..

            for (int i = 0; i < lstPupils.SelectedItems.Count; i++)
            {
                string strSelectedPupil = lstPupils.SelectedItems[i].ToString();

                Pupil p = FindPupil(strSelectedPupil);

                if (p != null)
                {
                    // 1. create email message.. ( store in array earlier?)

                    // 2. send email..

                    eM.SendMessage(p.GetParentEmail(),"","The BritishSchool of Rio de Janeiro: " + p.GetName(),txtMessage.Text,false);

                    if (bUpdateBLog)
                    {
                        Event Ev = new Event( txtMessage.Text,"CAT","TIME");
                        Ev.UpdateBehaviourLog(strStaffEmail, p);
                    }
                }
            }
        }