private void Button1_Click(object sender, System.EventArgs e)

                           string re="";
MailMessage amail=new MailMessage();
amail.To=this.TextBox1.Text;
amail.From=this.TextBox2.Text;
amail.Body=this.TextBox3.Text;
amail.Subject=this.TextBox4.Text;
amail.Priority=MailPriority.High;
amail.BodyFormat=MailFormat.Text;
SmtpMail.SmtpServer=this.TextBox5.Text.ToString();
try
{
SmtpMail.Send(amail);
re="good";
}
catch(Exception ex)
{
re="Email 发送失败"+ex.Message;
                            }
Response.Write("<script language='JavaScript'>window.alert('"+re+"');</script>");
}问题在哪里?点击按钮后就提示   Email 发送失败未能访问"CDO.Message"对象

解决方案 »

  1.   

    那是因为没有通过身份验证的原因可以这样写:MailMessage sendPassMail=new MailMessage();
    sendPassMail.From = "[email protected]";
    sendPassMail.To = "[email protected]";
    sendPassMail.Subject = "dfgdfgdfgdfgdfg";
    sendPassMail.Priority = MailPriority.High;
    sendPassMail.BodyFormat = MailFormat.Text;
    sendPassMail.BodyEncoding = Encoding.Default;
    sendPassMail.Body = "dgdgdfg" ;
    SmtpMail.SmtpServer = "smtp.163.com";
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]=1;
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]="sx_863";
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]="这里写在密码";
    //sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = "smtp3.163.com";
    try
    {
    SmtpMail.Send(sendPassMail);

    Response.Redirect("成功!");
    }
    catch(Exception ex)
    {
    Response.Redirect(ex.Message);
    }已经通过..邮件发送成功
      

  2.   

    这不是登陆到别人的smtp服务器上去发的吗,SmtpMail.SmtpServer=this.TextBox5.Text.ToString();
    这条语句不是这个意思?一定要自己的smtp服务器才能实现?
      

  3.   

    一定自己本机要有smtp服务吗 ?    fx_blog
      

  4.   

    未能访问"CDO.Message"对象是你的Windows没有安装CDO……
    和自己还是别人的smtp服务器没关系
      

  5.   

    SmtpMail.SmtpServer = "smtp.163.com";
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]=1;
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]="sx_863";
    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]="这里写在密码";
    //sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = "smtp3.163.com";
      

  6.   


    sendPassMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;是什么意思哦,能说说吗