代码:

        MailMessage message = new MailMessage(from, to,"","");
        //message.Subject = "nnnnnnn";
        //message.Body = "aaaaa";
        message.IsBodyHtml = false;
        message.BodyEncoding = System.Text.Encoding.UTF8;
        SmtpClient client = new SmtpClient("mail.jonng.com");
        // Credentials are necessary if the server requires the client
        // to authenticate before it will send e-mail on the client's behalf.
        client.UseDefaultCredentials = false;
        client.Port = 25;
        client.Credentials = new NetworkCredential("lymph@jonng.com", "保密");

        //client.Credentials;
        client.Send(message);



web.config 设置
  <system.net>
    <mailSettings>
      <smtp from="lymph@jonng.com">
        <network host="mail.jonng.com" password=" " userName="lymph@jonng.com" defaultCredentials="false"/>
      </smtp>
    </mailSettings>
  </system.net>

用以上设死活都提示邮件标题有问题,怎样都发不出去,但用.NET 1.0的代码一发就可以了,真是怪事啊~

.NET 1.0的代码

        MailMessage mail = new MailMessage();
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "lymph@jonng.com");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", " ");
        mail.BodyFormat = MailFormat.Html;

        mail.From = "lymph@jonng.com";
        mail.To = txtEmail.Text;
        mail.Subject = "adfadf";
        mail.Body = "asdfsadfsd";

        SmtpMail.SmtpServer = "mail.jonng.com";
        SmtpMail.Send(mail);

相关文章:

  • 2021-11-26
  • 2021-11-18
  • 2021-05-09
  • 2022-12-23
  • 2021-11-25
  • 2021-10-01
  • 2022-12-23
  • 2021-07-27
猜你喜欢
  • 2021-04-11
  • 2021-11-28
  • 2021-10-12
  • 2022-12-23
  • 2022-01-02
  • 2021-09-13
  • 2021-10-20
相关资源
相似解决方案