C# SmtpClient小例子

一个在C#中发送邮件的小例子

引用的命名空间

using System.Net.Mail;
SmtpClient sc = new SmtpClient("smtp.163.com");

    sc.Credentials = new NetworkCredential("userName", "password");

    MailMessage mm = new MailMessage("[email protected]", "[email protected]");

    mm.Subject = "主题";

    mm.Body = "邮件正文";

    Attachment tt = new Attachment(HttpRuntime.AppDomainAppPath + "a.txt");

    mm.Attachments.Add(tt);



    sc.Send(mm);

你可能感兴趣的:(client)