【问题标题】:How to send emails from my web application? [duplicate]如何从我的 Web 应用程序发送电子邮件? [复制]
【发布时间】:2010-04-22 21:56:08
【问题描述】:

可能的重复:
ASP.NET- Sending an e-mail
how to send mail using C#?

如何从我的 ASP.NET Web 应用程序发送电子邮件?

【问题讨论】:

标签: asp.net


【解决方案1】:

这是一个例子

MailMessage mailMessage = new MailMessage(new MailAddress("sender@email.com", "Sender Name"), new MailAddress("email@email.com"));
mailMessage.Subject = "Some subject";
mailMessage.Body = msg;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);

在 web.config 中设置配置

 <system.net>
<mailSettings>
  <smtp>
    <network
         host="mail.email.com"
         port="587"
         userName="user@email.com"
         password="xxxx" />
  </smtp>
</mailSettings>

【讨论】:

    【解决方案2】:

    使用SmtpClientMailMessage 类。

    【讨论】:

      猜你喜欢
      • 2019-09-11
      • 1970-01-01
      • 1970-01-01
      • 2020-05-28
      • 2010-12-27
      • 2010-12-20
      • 2014-11-03
      • 2013-09-21
      • 2015-03-26
      相关资源
      最近更新 更多