protected void btnSent_Click(object sender, EventArgs e)
{
SendEmail("SMTP.163.COM", "mailto:baikongbujin@163.com", "密码", "mailto:ruanjiandidai@163.com", "测试邮箱", "测试163邮箱");
}
private void SendEmail(string server, string username, string password, string toaddr, string titel, string body)
{
try
{
MailMessage msg = new MailMessage();
//发送到
msg.To.Add(toaddr);
msg.From = new MailAddress(username, titel, System.Text.Encoding.UTF8);
//标题
msg.Subject = titel;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
//内容
msg.Body = body;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = true;
//优先级
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.EnableSsl = false;
client.Credentials = new System.Net.NetworkCredential(username, password);
client.Port = 25;
client.Host = server;
client.EnableSsl = false;
client.Send(msg);
}
catch ()
{
}
}