一个在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);

相关文章:

  • 2022-12-23
  • 2021-06-26
  • 2021-06-13
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-01-19
猜你喜欢
  • 2021-05-22
  • 2021-08-26
  • 2022-02-10
  • 2022-02-11
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案