看过一篇这方面的文章,网址如下:
               http://www.cnblogs.com/dsclub/archive/2005/02/04/102082.aspx
   对这里登陆SMTP的一段不明白,而且我的机器总是提示“未能访问‘CDO.Message’对象。”我的机器装的是2003 Server,还请各位高手指点!!!

解决方案 »

  1.   

    using System;
    using System.Web.Mail;
    using System.Text;
    using Com.iFlytek.Utility;
    using iFlytek.iAvp.Access ;
    using System.Configuration;
    namespace FeeCommon
    {
    /// <summary>
    /// 邮件发送类。
    /// </summary>
    public class Email
    {   string MyMailFrom;
    string EmailServer;
    string EmailName;
    string EmailPassword;
    string AdminEmail;
    string SendToAdmin;
    public static AppSettingsReader cfg = new AppSettingsReader();
    public Email()
    {
    MyMailFrom= (string)cfg.GetValue("MyMailFrom" , typeof(string) );
    EmailServer= (string)cfg.GetValue("SmtpServer" , typeof(string) );
    EmailName= (string)cfg.GetValue("EmailName" , typeof(string) );
    EmailPassword= (string)cfg.GetValue("EmailPassword" , typeof(string) );
    AdminEmail=(string)cfg.GetValue("AdminEmail" , typeof(string) );
    SendToAdmin=(string)cfg.GetValue("SendToAdmin" , typeof(string) );
    }
    public bool SendEmail(string From , string To , string subject ,string Body,string sSubstr )
    { MailMessage MyMail = new MailMessage();
    MyMail.From = MyMailFrom;
    MyMail.To = To;
    MyMail.Subject =subject;
    MyMail.Body = "  ";
    //判断是否每一封邮件都要发一份到管理员邮箱
    if(SendToAdmin=="yes")  
      MyMail.Cc = AdminEmail;
    //MyMail.Bcc = sBcc;
    //MyMail.UrlContentBase = sUrlContentBase;
    //MyMail.UrlContentLocation = sUrlContentLocation;
            MyMail.BodyEncoding = Encoding.Unicode;
    MyMail.BodyFormat = MailFormat.Text;      MyMail.Priority = MailPriority.High;                 
    if(sSubstr!="")
    {
    MailAttachment MyAttachment = new MailAttachment(sSubstr);

    MyMail.Attachments.Add(MyAttachment);
    }

            
    MyMail.Headers.Add("iFlytek", "www.iflytek.com" );
    MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
    MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", EmailName); //set your username here 
    MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",EmailPassword); //set your password here  SmtpMail.SmtpServer =EmailServer;
    try
    {
    SmtpMail.Send(MyMail);
    Console.WriteLine("{0}邮件发送成功" ,subject);
    return true;
    }
    catch(Exception ex)
    {  
    Log.WriteToFile("",subject+"邮件发送失败");
                   Console.WriteLine("{0}邮件发送失败"+ex.Message.ToString(), subject);
    return false;
    }

    }
    }
    }
    用我的这个类吧 我自己用没有问题的
      

  2.   

    没有 Com.iFlytek.Utility, iFlytek.iAvp.Access这两个啊
      

  3.   

    using Com.iFlytek.Utility;
    using iFlytek.iAvp.Access;
    这两句编译时有问题,怎么样设置?
      

  4.   

    CSDNATM(青蛙)给我一份原码,我正遇到这个问题.谢谢了
      

  5.   

    能否发一份给我啊?
    谢谢.
    [email protected]
      

  6.   

    樓上的朋友,機器提示你“未能访问‘CDO.Message’对象。”是因為你有開防火牆,防火牆把你的發送mail的端口25給關了。我也遇到過此類問題。我用的系統是win2003 server 繁體的,防毒軟件是"mcafee",和你的代碼沒有關係!!
      

  7.   

    如果你是用代理上网基本上没戏qfkx.com
      

  8.   

    现在这谢谢了,我也想要一份
    [email protected]