NETFrame2.0下的<system.net>
    <mailSettings>
<smtp from="[email protected]">
    <network host="smtp.126.com" userName="[email protected]" port="25" password="**********" defaultCredentials="false"/>
</smtp>
    </mailSettings>
</system.net><system.net>
    <mailSettings>
<smtp from="[email protected]">
    <network host="smtp.126.com" userName="[email protected]" password="1234567" port="25" defaultCredentials="false"/>
</smtp>
    </mailSettings>
</system.net>
为什么我看到网上的资料说的都是<network host="mail.126.com" userName="[email protected]" password="1234567" port="25" >
但实际上是<network host="smtp.126.com" userName="[email protected]" password="1234567" port="25" > 这个密码为什么必须要写明呢,  但是资料上却都是***的,
高人指点下啊-----

解决方案 »

  1.   

    private void SendEmail(string server, string username, string password, string toaddr, string titel, string body)
            {
                try
                {
                    MailMessage msg = new MailMessage();
                    //发送到
                    msg.To.Add(toaddr);
                    msg.From = new MailAddress(username, titel, System.Text.Encoding.UTF8);
                    //标题
                    msg.Subject = titel;
                    msg.SubjectEncoding = System.Text.Encoding.UTF8;
                    //内容
                    msg.Body = body;
                    msg.BodyEncoding = System.Text.Encoding.UTF8;
                    msg.IsBodyHtml = true;
                    //优先级
                    msg.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();
                    client.Credentials = new System.Net.NetworkCredential(username, password);
                    client.Port = 587;
                    client.Host = server;
                    client.EnableSsl = true;
                    client.Send(msg);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
      

  2.   

    必须写明啊,我博客里有个发mail的文章,你看看吧
      

  3.   

    还加什么密码啊,没用的,现在不是想用谁的Email发信就发信的时代了么。