private void SendButton_OnClick(object sender, RoutedEventArgs e) { try { using (var email = new MailMessage("*****@*****.**", "*****@*****.**")) { email.Subject = "Тема письма"; email.Body = "Тело письма"; using (var client = new SmtpClient("smtp.mail.ru")) { var user = tb_UserName.Text; var password = pb_Password.SecurePassword; client.Credentials = new NetworkCredential(user, password); client.EnableSsl = true; client.Send(email); } } } catch (Exception error) { MessageBox.Show(error.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } var dlg = new SendCompleteDialog(); dlg.Owner = this; dlg.ShowDialog(); }
private void SendButton_OnClick(object sender, RoutedEventArgs e) { string answer = EmailSendServiceClass.SendEmail(UserName_TextBox.Text, Password_PasswordBox.SecurePassword); if (answer != "Ok") { var errdlg = new ShowError(answer); errdlg.Owner = this; errdlg.ShowDialog(); } else { //MessageBox.Show("Почта отправлена успешно", "MailSender", MessageBoxButton.OK, // MessageBoxImage.Information); var dlg = new SendCompleteDialog(); dlg.Owner = this; dlg.ShowDialog(); } }