private void Button1_Click(object sender, System.EventArgs e)
{
MailMessage mymail = new MailMessage();
mymail.From = From.Text;
mymail.To = To.Text;
mymail.Subject = Subject.Text;
mymail.Body = Body.Text;
mymail.Fields.Add try
{
SmtpMail.Send(mymail);
msg.Text = "发送成功!!";
}
catch(System.Exception E)
{
msg.Text = E.ToString();
}
}
-------------------------------------------------------------------
出错信息:
System.Web.HttpException: 未能访问“CDO.Message”对象。 ---> System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> 

解决方案 »

  1.   

    http://www.google.com/search?hl=zh-CN&q=%E6%9C%AA%E8%83%BD%E8%AE%BF%E9%97%AE%E2%80%9CCDO.Message%E2%80%9D%E5%AF%B9%E8%B1%A1&btnG=Google%E6%90%9C%E7%B4%A2&lr=
      

  2.   

    这个或许对你有帮助
    try
    {

    MailMessage Objmail = new MailMessage();
    Objmail.To = mail.to;
    Objmail.From = mail.from;
    Objmail.Bcc = mail.bcc;
    Objmail.Cc = mail.cc;
    Objmail.Subject = mail.subject;
    Objmail.Body = mail.body;
    if(mail.attfile!="")
    {
    string sAttach = mail.attfile.ToString();
    char[] delim = new char[] {','};
    foreach (string sSubstr in sAttach.Split(delim))
    {
    MailAttachment MyAttachment = new MailAttachment(sSubstr);
    Objmail.Attachments.Add(MyAttachment);
    } }
    Objmail.UrlContentBase = "http://www.contoso.com/images";
    Objmail.UrlContentLocation = "http://www.contoso.com/images";
    Objmail.BodyFormat = MailFormat.Text;
    Objmail.Priority = MailPriority.Normal; Objmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    Objmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", ""+mail.username+"");
    Objmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ""+mail.password+""); SmtpMail.SmtpServer = mail.mailserver;

    SmtpMail.Send(Objmail);

    UpdateDataBase(sql);
    //return true;
    }
    catch(ThreadInterruptedException e)
    {
    }
      

  3.   

    Imports System
    Imports System.Web
    Imports System.Web.Mail
    Imports System.Collections
    Imports System.Data
    Imports System.Drawing
    Imports System.ComponentModel
    Imports System.Windows.FormsDim mails As New MailMessage()Try
                If Me.TextBox2.Text = "" Then
                    MsgBox("请输入收件人地址", MsgBoxStyle.OKOnly, "提示")
                    Return
                Else            End If
                If Me.TextBox3.Text = "" Then
                    MsgBox("请输发收件人地址", MsgBoxStyle.OKOnly, "提示")
                    Return
                End If            If Me.TextBox4.Text = "" Then
                    MsgBox("请输入主题", MsgBoxStyle.OKOnly, "提示")
                    Return
                End If
                mails.To = Trim(Me.TextBox2.Text)
                mails.From = Trim(Me.TextBox3.Text)
                mails.Subject = Trim(Me.TextBox4.Text)
                mails.BodyFormat = MailFormat.Html
                mails.Priority = MailPriority.High
                mails.Body = Trim(Me.TextBox1.Text)
                SmtpMail.Send(mails)
                
                MsgBox("发送成功", MsgBoxStyle.OKOnly, "提示")
            Catch ex As Exception
                MsgBox("发送不成功", MsgBoxStyle.OKOnly, "出错")
            End Try
      

  4.   

    http://community.csdn.net/Expert/topic/3619/3619688.xml?temp=.9775659
      

  5.   

    你没有加验证所以发不出去了,你把下面的代码加上再试试
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //basic authentication 
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","[email protected]"); //set your username here 
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","qwer-123"); //set your password here  可以了,加上这些就可以了!