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); } }
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); } } } }