发邮件代码那里错了??
using System.Web.Mail;
private void button6_Click(object sender, System.EventArgs e)
{
try
{
MailMessage mm=new MailMessage();
mm.BodyFormat=MailFormat.Text;
mm.To=this.textBox1.Text.Trim();
mm.From=this.textBox2.Text.Trim();
mm.Subject=this.textBox4.Text.Trim();
mm.Body=this.textBox3.Text.Trim();
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send(mm);
MessageBox.Show("ok");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString()); }


}

解决方案 »

  1.   

    出什么问题了。使用smtp.163.com,好像要用户信息
      

  2.   

    MailMessage mail = new MailMessage();
     mail.To = "[email protected]";
     mail.From = "[email protected]";
     mail.Subject = "this is a test email.";
     mail.Body = "Some text goes here";
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "AlleNny"); //set your username here
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Password"); //set your password here
     SmtpMail.SmtpServer = "smtp.163.com";  //your real server goes here
     SmtpMail.Send( mail );
      

  3.   

    另外:
       1、使用socket进行smtp编程。发送User和PWD等命令
       2、使用CDO的MessageClass
      

  4.   

    使用Socket发送:
         “EHLO ”+ mailserver + enter; 
          "AUTH LOGIN “+Base64Encode(username) + enter; 
                +Base64Encode(password) + enter;
      

  5.   

    还是不能发送,什么CDO的MESSAGE错误!!
      

  6.   

    要加上楼上fsdy2000说的身份验证,同是你的正文编码类型要设好,不然收到的中文会是乱码
      

  7.   

    我提供了三种方法,你就使用SmtpMail/MailMessage即可。
      

  8.   

    不是已经给你代码了吗?在你的代码中加入:
    mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");  mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");  mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
      

  9.   

    乡愁你好:
    add的第一个参数是什么意思?(如("http://schemas.microsoft.com/cdo/configuration/sendusername"), 必须要这样吗?我知其然不知其所以然呢??
    回答了我结分了
      

  10.   

    Fields属性是1.1版本中新增的,允许访问根本的(underlying) CDO.Message 域。第一个参数即是所访问的域,第二个参数是设定的值。