private void sendUpdateFROMToolStripMenuItem_Click(object sender, EventArgs e) { string target = Microsoft.VisualBasic.Interaction.InputBox("Who would you like to send an update from?", "Send an update FROM?").Trim(); List <Participant> matches = ParsedParticipants.Where(x => x.Name == target || x.Email == target) .ToList(); if (matches.Count > 1) { MessageBox.Show("Input matches more than one person.", "Multiple Matches!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else if (matches.Count < 1) { MessageBox.Show("Input matches no person.", "No Matches!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { string message = "Send an update email from " + matches[0].Name + "?"; if (DialogResult.Yes == MessageBox.Show(message, "Email Confirmation?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { sent = 0; toSend = 1; DrawingResult result = DrawingResult.PerfrormDrawings(ParsedParticipants).Where(x => x.Receiver.Equals(matches[0])).ToList()[0]; SendGmail(txtEmail.Text, txtPassword.Text, result.Giver.Email, "Secret Santa " + DateTime.Now.Year.ToString(), result.PrepareMessage(txtMessage.Text, txtEmail.Text)); } } }
private void testToolStripMenuItem_Click(object sender, EventArgs e) { try { List <DrawingResult> results = DrawingResult.PerfrormDrawings(Participant.ParseParticipants(txtParticipants.Text)); StringBuilder test = new StringBuilder(); foreach (DrawingResult result in results) { test.Append(result.Giver.Email).Append(" => ").AppendLine(result.Receiver.Email); } MessageBox.Show(test.ToString(), "Test Results", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void runToolStripMenuItem_Click(object sender, EventArgs e) { try { if (DialogResult.Yes == MessageBox.Show("Perform a drawing and send the emails?", "Email Confirmation?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { List <DrawingResult> results = DrawingResult.PerfrormDrawings(ParsedParticipants); sent = 0; toSend = results.Count; foreach (DrawingResult result in results) { SendGmail(txtEmail.Text, txtPassword.Text, result.Giver.Email, "Secret Santa " + DateTime.Now.Year.ToString(), result.PrepareMessage(txtMessage.Text, txtEmail.Text)); } } } catch (Exception exc) { MessageBox.Show(exc.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }