一个在C#中发送邮件的小例子
引用的命名空间
using System.Net.Mail;
SmtpClient sc = new SmtpClient("smtp.163.com"); sc.Credentials = new NetworkCredential("userName", "password"); MailMessage mm = new MailMessage("from@163.com", "to@qq.com"); mm.Subject = "主题"; mm.Body = "邮件正文"; Attachment tt = new Attachment(HttpRuntime.AppDomainAppPath + "a.txt"); mm.Attachments.Add(tt); sc.Send(mm);