//Send Email
private void emailSend(string code)
{this
//驗證發生的郵件地址不能爲空;
if (String.IsNullOrWhiteSpace(this.txtUserMail.Text))
{
showErr("郵件地址");
return;
}
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(this.txtUserMail.Text);//收件人郵箱
mailMessage.From = new MailAddress("wefwerf@qq.com", "Test", System.Text.Encoding.UTF8);code
mailMessage.Subject = "this is a Test.";
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;string
mailMessage.Body = "你申請的驗證碼是:" + code ;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;it
mailMessage.IsBodyHtml = false;
mailMessage.Priority = MailPriority.High;io
SmtpClient smtpClient = new SmtpClient();
smtpClient.Credentials = new System.Net.NetworkCredential("ergferge@qq.com", "ergerg");
smtpClient.Host = "smtp.exmail.qq.com";
object userState = mailMessage;
try
{
smtpClient.SendAsync(mailMessage, userState);
showErr("驗證碼已經發送到你的郵箱中,", "請注意查收!");
}
catch (SmtpException ex)
{
showErr("發生失敗!緣由:", ex.ToString());
}
}驗證碼