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.
            }
        }
예제 #2
0
        public void SendMessage(string strTo, string strCC, string strSubject, string strMessage, bool bCopyYH)
        {
            // This is: "Mail To"..
            MailAddress to = new MailAddress(strTo);

            // This is: "Mail From"..
            MailAddress from = new MailAddress(strFromEmail);

            MailMessage mail = new MailMessage(from, to);
            mail.Subject = strSubject;
            mail.Body = strMessage;

            // copy year head..

            // Add a carbon copy recipient..

            if (bCopyYH)
            {
                MailAddress copy = new MailAddress(strCC);
                mail.CC.Add(copy);
            }
            // set up client and send email..

            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;

            smtp.Credentials = new NetworkCredential(strFromEmail, strPassword);
            smtp.EnableSsl = true;

            if (bCopyYH == false)
            {
                strCC = "";
            }

            ConvertChars c = new ConvertChars();

            DialogResult r = MessageBox.Show("Proceed with: " + c.NL() + "To: " + strTo + c.NL() + "cc: " + strCC + c.DoubleNL() + "Re: " + strSubject + c.DoubleNL() + strMessage, "Send Message", MessageBoxButtons.YesNo);

            if (r == DialogResult.Yes)
            {
                smtp.Send(mail);
                MessageBox.Show("Message Sent");
            }
            else
            {
                MessageBox.Show("Message was not sent");
            }

        }
        private void MessageTeacher_Load(object sender, EventArgs e)
        {
            lblTitle.Text = "";
            ConvertChars c = new ConvertChars();

            // get the staff emails from the array..

            for (int i = 0; i < staffGrp.GetStaffCount(); i++)
            {
                // add the staff name..

                lstTeachers.Items.Add(staffGrp.FindStaffFirstName(i));

                // add the staff title..

                lblTitle.Text += staffGrp.FindStaffTitle(i) + c.NL();
            }
        }
예제 #4
0
        public string UpdatePhrase( string strName, bool bIsMale)
        {
            ConvertChars c = new ConvertChars();

            switch (nPhraseIndex++)
            {
                case 0:
                    strCurrentPhrase = c.ConvertNameAndGender(strName, bIsMale, strPhrase1);
                    break;
                case 1:
                    strCurrentPhrase = c.ConvertNameAndGender(strName, bIsMale, strPhrase2);
                    break;
                case 2:
                    strCurrentPhrase = c.ConvertNameAndGender(strName, bIsMale, strPhrase3);
                    break;
                case 3:
                    return strCurrentPhrase;
                default:
                    return "";
            }

            return strCurrentPhrase;
        }