在ASP.NET中发邮件!


Posted on May 24, 2008


using System.Net.Mail; 

MailMessage mm = new MailMessage(emailfrom.Text, emailto.Text);

mm.Subject = subject.Text;
mm.Body = body.Text;
mm.IsBodyHtml = true;

SmtpClient sc = new SmtpClient();
sc.Send(mm);

上面是核心代码,在web.config里面须配置:

<system.net> 
<mailsettings>
<smtp> <network host="smtp.qq.com" port="25" username="******@qq.com" password="****"></network> </smtp>
</mailsettings>
</system.net>

标签:N/A

 

在线学习答案查询入口
微信扫一扫
微信扫码联系