<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
    </system.web>
  <system.net>
    <mailSettings>
      <smtp from="发件人邮箱">
        <network host="服务器地址比如:SMTP.163.COM" password="发件人邮箱密码" userName="发件人用户名"/>
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

解决方案 »

  1.   

    不仅web.config中要配置,后台也要写代码的。
      

  2.   

     我的代码,给看看啊,怎么才能好用啊protected void btnSend_Click(object sender, EventArgs e)
        {
            MailMessage mm = new MailMessage();        // 发件人地址,也可以在MailMessage的构造函数里设置
            MailAddress ma = new MailAddress(emailfrom.Text);        mm.From = ma;
            // 多个收件人地址,可以用Add继续添加
            mm.To.Add(emailto.Text);
            mm.Subject = subject.Text;
            mm.Body = body.Text;        SmtpClient sc = new SmtpClient();
            sc.Send(mm);
        }