开发者

How to send emails from my web application? [duplicate]

开发者 https://www.devze.com 2022-12-28 07:14 出处:网络
This question already has answers here: 开发者_如何学Python Closed 12 years ago. Possible Duplicates:
This question already has answers here: 开发者_如何学Python Closed 12 years ago.

Possible Duplicates:

ASP.NET- Sending an e-mail

how to send mail using C#?

How can I send emails from my ASP.NET web application?


Here is an example

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);

Setup configuration in web.config

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


Use the SmtpClient and the MailMessage classes.

0

精彩评论

暂无评论...
验证码 换一张
取 消