.net发送Email
[code="c#"] 1./// 2./// 发送EMail 3./// 4./// 标题 5./// 内容 6./// 发送到哪 7./// 从哪发送 8./// 用户名 9./// 密码 10./// smtp服务器 11.private void sendMail(string title, string body, string toAdress, string fromAdress, 12. string userName, string userPwd, string smtpHost) 13.{ 14. try 15. { 16. MailAddress to = new MailAddress(toAdress); 17. MailAddress from = new MailAddress(fromAdress); 18. System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to); 19. message.Subject = title; message.Body = body; 20. SmtpClient smtp = new SmtpClient(); 21. smtp.UseDefaultCredentials = true; 22. smtp.Port = 25; 23. smtp.Credentials = new NetworkCredential(userName, userPwd); 24. smtp.DeliveryMethod = SmtpDeliveryMethod.Network; 25. smtp.Host = smtpHost; 26. message.To.Add(toAdress); 27. smtp.Send(message); 28. } 29. catch (Exception ex) { 30. Response.Write(ex.Message); 31. } 32.} [/code]