最好有例子,急着用

解决方案 »

  1.   

    //安装Jmail,把jmail引用到工程中,加入jmail的命名空间,引用jmail包的messageclass类。
    public bool sendMail(){         MessageClass email = new MessageClass();          email.Logging = true;          email.Silent = true;          email.MailServerUserName = "[email protected]";          email.MailServerPassWord = "124";          email.From = "[email protected]";                  email.Subject = "jmail";          email.AddAttachment("c:\\test.xml",true,"");           email.Body = "test jmail send mail";                  email.AddRecipient("[email protected]", "abc", null);          return email.Send("mail.163.com", false)      }
      

  2.   

    Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage                                Message.From = EmailFrom
                                    Message.To = MailTo
                                    Message.Subject = Major
                                    Message.Body = body                                Message.BodyEncoding = System.Text.Encoding.Default
                                    Message.BodyFormat = System.Web.Mail.MailFormat.Html '用HTML格式                                Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
                                    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", LoginName)
                                    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", PassWord)                                                                    Message.Attachments.Add(New MailAttachment(附件))
                                                                                                     
                                    SmtpMail.SmtpServer = EmailServerIp '設定SMTP服務器地址
                                    SmtpMail.Send(Message)
      

  3.   

    using System;
    using System.Web.Mail;
    public class CSendEail
    {
    public static void Main()
    {
    try
    {
    SmtpMail.SmtpServer = "localhost";
    MailMessage oMsg = new MailMessage();
    oMsg.From = "[email protected]";
    oMsg.To = "[email protected]";
    //oMsg.Cc = "[email protected]";
    oMsg.Subject = "My Custom Mail";
    oMsg.Body = "This is only a test";
    //oMsg.Attachments.Add(new MailAttachment("e:\\send.cs"));
    SmtpMail.Send(oMsg);
    Console.WriteLine("Send Success") ;
    }
    catch(Exception e)
    {
    Console.WriteLine(e.Message) ;
    //Console.WriteLine("Send Fail") ;
    }
    }
    }
    代理服务器
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
      

  4.   

    DataRow dr = DataAccess.GetInstance().GetDataRowById(mailId.ToString(),7); //实例化MailMessage对象 
    System.Web.Mail.MailMessage mail=new System.Web.Mail.MailMessage(); 
     
    //定义邮件的发送地址 
    mail.From = dr[1].ToString(); 
     
    //定义邮件的接收地址 
    //设置以分号分隔的收件人电子邮件地址列表 
    mail.To = strEmail; 
     
    //定义邮件的主题 
    mail.Subject = dr[5].ToString(); 
     
    //设置电子邮件正文的内容类型 
    //在这里我们以HTML的格式发送 
    mail.BodyFormat=System.Web.Mail.MailFormat.Html; 
     
    //设置电子邮件的正文 
    mail.Body = dr[6].ToString() + url; 
     
    //SMTP服务器 
    //许多SMTP服务器都需要身份验证 
    System.Web.Mail.SmtpMail.SmtpServer = dr[2].ToString(); 
     
    //验证 
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");  
    //登陆名 
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", dr[3].ToString());  
    //登陆密码 
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", dr[4].ToString());  
     
    //发送 
    System.Web.Mail.SmtpMail.Send(mail); 那些dr[1].ToString();  dr[2].ToString();  是从数据库里取!
      

  5.   

    刚刚好我也在做发EMAIL这个功能,有什么问题来问我吧!