using System.Net.Mail;
private void btnSend_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]", "user", Encoding.UTF8);
mail.To.Add("[email protected]"); mail.Subject = "测试邮件";
mail.SubjectEncoding = Encoding.UTF8;
mail.Body = "这是邮件内容";
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Priority = MailPriority.High; //SMTP
SmtpClient client = new SmtpClient("smtp.gmail.com", 465);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password"); //object userState = mail; try
{
client.Send(mail);
MessageBox.Show("发送成功");
}
catch (SmtpException ex)
{
Console.WriteLine("错误提示: " + ex.Message);
}
}
private void btnSend_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]", "user", Encoding.UTF8);
mail.To.Add("[email protected]"); mail.Subject = "测试邮件";
mail.SubjectEncoding = Encoding.UTF8;
mail.Body = "这是邮件内容";
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Priority = MailPriority.High; //SMTP
SmtpClient client = new SmtpClient("smtp.gmail.com", 465);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password"); //object userState = mail; try
{
client.Send(mail);
MessageBox.Show("发送成功");
}
catch (SmtpException ex)
{
Console.WriteLine("错误提示: " + ex.Message);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货