C#发送邮件笔记
1 public static int SendtoMail(string mail, string subject, string value) 2 { 3 MailAddress EmailFrom = new MailAddress("cowkeys@163.com"); 4 MailAddress EmailTo = new MailAddress(mail); 5 6 MailMessage Email = new MailMessage(EmailFrom, EmailTo); 7 Email.Priority = MailPriority.Normal; 8 9 Email.Subject = subject; 10 Email.Body = value; 11 12 //服务器要根据邮箱的地址来决定 13 SmtpClient Client = new SmtpClient("smtp.163.com"); 14 Client.Credentials = new System.Net.NetworkCredential("cowkeys", "×××密码"); 15 Client.DeliveryMethod = SmtpDeliveryMethod.Network; 16 try 17 { 18 Client.Send(Email); 19 return 1; 20 } 21 catch (Exception) 22 { 23 return 0; 24 } 25 }
mail是你要发送的邮件地址,subject是邮件主题,value是正文。
参考的原文地址:http://www.cnblogs.com/wangshuai/archive/2010/06/13/1757708.html