private void EmailButton_Click(object sender, RoutedEventArgs e) { string text = EmailBox.Text; string subEmail = EmailTextBox.Text; string email = text + "@" + EmailTextBox.Text; new Task(() => { DataManager.VerifyCode(email); }).Start(); MessageBox.Show("이메일이 전송되었습니다.\n이메일 전송은 최대 30초까지 소요될 수 있습니다."); if (timer == null) { timer = new Timers(); timer.timerevent += TImerEventSender; timer.Strat(301); } else { timer.SetTime(301); } EmailVerifyCanvas.Visibility = Visibility.Visible; }
private void EmailButton_Click(object sender, RoutedEventArgs e) { string text = EmailBox.Text; string subEmail = EmailTextBox.Text; string email = text + "@" + EmailTextBox.Text; try { // Credentials var credentials = new NetworkCredential("*****@*****.**", "password"); // Mail message using (var mail = new MailMessage() { IsBodyHtml = true, From = new MailAddress("*****@*****.**"), Subject = "[인증코드]TEAMDATABASE", Body = "<p>당신의 인증코드는 다음과 같습니다.</p><hr><b>" + DataManager.VerifyCode(email) + "</b><hr>" }) { mail.To.Add(new MailAddress(email)); // Smtp client using (var client = new SmtpClient() { Port = 587, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Host = "smtp.gmail.com", EnableSsl = true, Credentials = credentials }) { // Send it... client.Send(mail); if (timer == null) { timer = new Timers(); timer.timerevent += TImerEventSender; timer.Strat(301); } else { timer.SetTime(301); } } } } catch (Exception ex) { Debug.WriteLine("Error in sending email: " + ex.Message); MessageBox.Show("ERRORR\n" + ex.Message); return; } EmailVerifyCanvas.Visibility = Visibility.Visible; Console.WriteLine("Email sccessfully sent"); }