win form 下怎么样用C#来发送邮件??win form 情况下 C#里面好像没有vb的发邮件功能简单,哪位知道怎么发送?????????

解决方案 »

  1.   

    namespace CdoSys
    {
        using System;
        class Class1
        {
            static void Main(string[] args)
            {
                try
                {
                CDO.Message oMsg = new CDO.Message();
                CDO.Configuration iConfg = new CDO.Configuration();
                ADODB.Fields oFields;
                ADODB.Field oField;            oFields = iConfg.Fields;            
                oField =
    oFields["http://schemas.microsoft.com/cdo/configuration/smtpsserver"];
    oField.Value = "smarthost";            oField =
    oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"];
    oField.Value =25;            oFields.Update();            oMsg.Configuration = iConfg;            // Set common properties for Message
                oMsg.Subject = "Test SMTP";
                oMsg.From = "[email protected]";
                oMsg.To = "[email protected]";            oMsg.Send();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
                return;
            }
        }
    }
      

  2.   

    用Mail类,到搜索网站www.baidu.com搜索一下:"C# Main 发送邮件"
      

  3.   

    C#中有一个Email的类。
    不过不太好使,要用自己的邮件服务器。
    一般的邮件服务器都需要验证的。
      

  4.   

    http://helloworld84.cnblogs.com/archive/2005/09/02/229063.html
      

  5.   

    public class SystemMail
         {
     private string _adminEmail;
     private string _smtpServer = "localhost";
             private string _password;
             private string _userName;
             public SystemMail()
             {  
             }
             public string AdminEmail
             {              get{return _adminEmail;}
                  set{_adminEmail = value;}
             } 
             public string SmtpServer
             {
                  get{return _smtpServer;}
                  set{_smtpServer = value;}
             }
             public string Password
             {
                  get{return _password;}
                  set{_password = value;}
             }
             public string UserName
             {
                  get{return _userName;}
                  set{_userName = value;}
             }
             public bool Send(string to, string from, string subject, string message)
             {
                  try
                  {
                       MailMessage em = new MailMessage();
                       em.To = to;
                       em.From = from;
                       em.Subject = subject;
                       em.Body = message;
                       //Found out how to send authenticated email via System.Web.Mail at http://SystemWebMail.com (fact 3.8)
                       if(this.UserName != null && this.Password != null)
                       {                      em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");   //basic authentication                       em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here                       em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here                   }
                       SmtpMail.SmtpServer = this.SmtpServer;
                       SmtpMail.Send(em);
                       return true;
                  }
                  catch
                  {
                       return false;
                  }
              }
         }
      

  6.   

    using System.Web.MailMailMessage mm = new MailMessage();
    mm.Body = "";
    mm.** ="";
    Smtp*** .Send(mm);