不管我怎么样,总是提示说发送失败,服务器不支持安全连接,请各位大侠帮我看看,谢谢!!!
 
protected void Button3_Click(object sender, EventArgs e)
    {
            MailMessage mailMessage = new MailMessage();
            string strBody;            mailMessage.From = new MailAddress("####@126.com");
            mailMessage.To.Add("#####@cswrtz.com");//企业邮箱
            mailMessage.Subject = "速取黑马";            strBody = "<h2>" + this.TextBox5 + "</h2><br><h2>" + this.DropDownList1.SelectedValue + "</h2><br><h2>" + this.TextBox6 + "</h2><br><h2>";
        
            sendMail(mailMessage);      
}
    public void sendMail(MailMessage mail)
    { 
       SmtpClient smtpClient = new SmtpClient();
            smtpClient.EnableSsl = true;
            smtpClient.Host = "smtp.126.com";
            smtpClient.Port = 25;
            smtpClient.Credentials = new System.Net.NetworkCredential("####", "####");
            
        try
            {
                smtpClient.Send(mail);
                colse();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
            }    }

解决方案 »

  1.   

    public   void   CDOsendMail(string   f_email,string   t_email,string   zh,string   mm) 

    try 
    {         
    CDO.Message   oMsg   =   new   CDO.Message(); 
            
    oMsg.From   =   f_email; 
    oMsg.To   =   t_email; 
    oMsg.Subject   =   "东风威客取回密码 "; 
                                      
    oMsg.HTMLBody   =   " <html > <body >这是您的帐号信息: <br >帐号: "+zh+ " <br >密码: "+mm+ " <br > <a   href= &apos;http://www.33419.cn &apos; >东风工作室 </a > </body > </html > "; 
    CDO.IConfiguration   iConfg   =   oMsg.Configuration; 
    ADODB.Fields   oFields   =   iConfg.Fields; 
                        
    oFields[ "http://schemas.microsoft.com/cdo/configuration/sendusing "].Value=2; 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/sendemailaddress "].Value=f_email;   //sender   mail 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpaccountname "].Value=f_email;   //email   account 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/sendusername "].Value= "roamabout "; 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/sendpassword "].Value= "kk123 ";   
    oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate "].Value=1; 
    //value=0   代表Anonymous验证方式(不需要验证) 
    //value=1   代表Basic验证方式(使用basic   (clear-text)   authentication.   
    //The   configuration   sendusername/sendpassword   or   postusername/postpassword   fields   are   used   to   specify   credentials.) 
    //Value=2   代表NTLM验证方式(Secure   Password   Authentication   in   Microsoft   Outlook   Express) 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/languagecode "].Value=0x0804; 
    oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpserver "].Value= "smtp.126.com "; 
    oFields.Update(); 
    oMsg.BodyPart.Charset= "gb2312 "; 
    oMsg.HTMLBodyPart.Charset= "gb2312 ";   
    oMsg.Send(); 
    oMsg   =   null; 
    }       
    catch   (Exception   e) 

    throw   e; 

    } 再添加一个引用,如果你是xp系统请到c:\windiws下找到cdosys.dll,如果是2000到c:\winnet找cdosys.dll(不要说不会添加引用吧???)
      

  2.   

    roamabout  麻烦你好人做到底,帮我分析一下,到底是什么原因,本地调试可以发送成功,我上传了以后就不行了
    而且报的错我也看不明白。 谢谢
      

  3.   

    public static void sendMails(string tomail,string subject,string body)

    MailMessage objMailMessage;
    //创建邮件信息
    objMailMessage = new MailMessage();
    objMailMessage.From="[email protected]";
    objMailMessage.To=tomail;
    objMailMessage.BodyFormat=MailFormat.Html;
    objMailMessage.Subject=subject;
    objMailMessage.Body=body; //接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本 //基本权限
    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    //用户名
    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "mailname") ;
    //密码
    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "********"); //如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied  //SMTP地址
    SmtpMail.SmtpServer = "smtp.163.com"; //开始发送邮件
    SmtpMail.Send( objMailMessage ); }
      

  4.   

     楼上的兄弟,你用的不是asp.net2.0吧