110,963
社区成员
发帖
与我相关
我的任务
分享
MailMessage mail = new MailMessage();
mail.To.Add("XXXXX@163.com");
mail.From = new MailAddress("XXXXX@163.com", "XXXXX", Encoding.UTF8);
mail.Subject = "test";
mail.SubjectEncoding = Encoding.UTF8;
mail.Body = "testmail";
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Priority = MailPriority.High;
//SMTP
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("username", "password");
client.Host = "smtp.163.com";
object userState = mail;
try
{
client.Send(mail);
Console.WriteLine("Successful");
}
catch (SmtpException ex)
{
Console.WriteLine("Err: " + ex.Message);
}