如何用c#发邮件


Posted on May 9, 2007


System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.163.com");
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("jmisenjoying@163.com", "**********");  //帐号密码
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.From = new System.Net.Mail.MailAddress("jmisenjoying@163.com", "jm", System.Text.Encoding.UTF8);
message.To.Add(new System.Net.Mail.MailAddress("jm-superstar@163.com", "jm", System.Text.Encoding.UTF8));
message.IsBodyHtml = false;
message.Subject = "test";
message.Body = System.DateTime.Now.ToLongDateString();
try
{
    client.Send(message);
}
catch
{
//...
}

标签:N/A

 

在线学习答案查询入口
微信扫码联系
微信扫码联系