private void BtnAddAddr_Click(object sender, RoutedEventArgs e) { string addr = emailToAdd.Text; if (addr == "") { return; } var task = new Task(() => { var service = NewEmailService(); char valid = service.ValidateEmailAddress(addr); if (valid == 'Y') { this.Dispatcher.BeginInvoke(new Action(() => { EmailAddrs.Add(addr); emailToAdd.Text = ""; })); } else { MessageBox.Show("Invalid email address!"); } }); task.Start(); }
private void BtnSend_Click(object sender, RoutedEventArgs e) { try { var service = NewEmailService(); char res = service.SendEmailBatch(EmailAddrs.ToArray(), Payload); MessageBox.Show(res == 'Y' ? "发送成功。" : "发送失败。"); }catch (Exception ex) { MessageBox.Show(ex.Message); } }