可以完成发送邮件功能的C#代码
实例如下:
public void SendMail(string from, string to, string subject, string body) { string mailServerName = "smtp.test.com"; try { //MailMessage represents the e-mail being sent using (MailMessage message = new MailMessage(from, to, subject, body)) { message.IsBodyHtml = true; SmtpClient mailClient = new SmtpClient(); mailClient.Host = mailServerName; mailClient.UseDefaultCredentials = true; mailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; //Send delivers the message to the mail server mailClient.Send(message); } } catch (SmtpException ex) { throw new ApplicationException ("SmtpException has oCCured: " + ex.Message); } catch (Exception ex) { throw ex; } }
来源:
Send Mails from within a .NET 2.0 Application
http://www.codeguru.com/csharp/csharp/cs_misc/e-mail/article.php/c9957