protected void Button1_Click(object sender, EventArgs e)
{
//String qqmail=Request["Textbox1"];
//声明一个Mail对象
MailMessage mail = new MailMessage();
//发件人地址
mail.From = new MailAddress("869759698@qq.com");
//收件人地址
mail.To.Add(new MailAddress(TextBox1.Text));
//邮件主题
mail.Subject = "注册验证";
//邮件标题编码
mail.SubjectEncoding = System.Text.Encoding.UTF8;
//邮件内容
mail.Body = "请点击以下链接激活你的账户 www.omooo.top";
//邮件内容编码
mail.BodyEncoding = System.Text.Encoding.UTF8;
//添加附件
// Attachment myfiles = new Attachment(Attachment.PostedFile.FileName);
// mail.Attachments.Add(myfiles);
//抄送到其他邮箱
// mail.CC.Add(new MailAddress(抄送地址));
//是否是HTML邮件
mail.IsBodyHtml = true;
//邮件优先级
mail.Priority = MailPriority.High;
//创建一个邮件服务器类
SmtpClient myclient = new SmtpClient();
myclient.Host = "smtp.qq.com";
//指定邮件发送方式
myclient.DeliveryMethod = SmtpDeliveryMethod.Network;
//SMTP端口
myclient.Port = 25;
myclient.EnableSsl = true;
//验证登录
myclient.Credentials = new NetworkCredential("869759698@qq.com", "unznmehvinqspbfdi");
myclient.Send(mail);
/*
try
{
myclient.Send(mail);
return true;
}
catch {
return false;
}
* */
}