用JMail组件或ASP.NET2.0自带的的System.Net.Mail类都可以,网上一堆堆的,自己查吧

解决方案 »

  1.   

    我找了个jmail 安上了,也引用了,  也照网上说的测试代码写了 但是为什么发不出去呢? 他也不会报错,就是发不出去,缺了什么?:
    public void s()
        {
            Message jmail = new Message();
            string t = "[email protected]";
            string f = "[email protected]";
            string sub = "ok";
            string body = "dddddddddddd";        jmail.Silent = true;
            //jmail.Version = "4.0.0.0";
            
            jmail.Charset = "gb2312";
            jmail.ContentType = "text/html";
            jmail.Logging = true;
            jmail.From = f;
            jmail.FromName = "lineagedove2017";
            jmail.Priority = 1;
            jmail.Encoding = "base64";
            jmail.ISOEncodeHeaders = false;
            jmail.AddRecipient(t, "", "");
            jmail.MailServerUserName = "lineagedove2017";
            jmail.MailServerPassWord = "l71201982j";
            jmail.Subject = sub;
            jmail.Body = body;
            jmail.Send("smtp.163.com", false);
            jmail.Close();
        }
        protected void sendout_ServerClick(object sender, EventArgs e)
        {
            try
            {
                //調用方法
                s();
            }
            catch(Exception ex) 
            {
                Response.Write("錯誤:"+ex.Message);
            }
        }
      

  2.   

    using CDO;
    public static void SendMail(string sfrom,string sto,string subject,string body)
    { CDO.Message Msg = new CDO.Message();
    Msg.From =sfrom;
    Msg.To = sto;
    Msg.Subject =subject;
    Msg.HTMLBody =body;
    Msg.BodyPart.Charset = "gb2312";
    Msg.HTMLBodyPart.Charset = "gb2312";
    Msg.MimeFormatted=true;
    Msg.Send();
    Msg = null; }
      

  3.   

    网上关于发送邮件的文章多的不行 
    public void SendMail(string mail,string subject,string body,bool isHtml)
    {
    MailMessage mailObj = new MailMessage(); mailObj.From = this._MailFrom;
    mailObj.To = mail; mailObj.Subject = subject;
    mailObj.Body = body; // html格式的邮件
    if (isHtml)
    {
    mailObj.BodyFormat = MailFormat.Html;
    }
    else
    {
    mailObj.BodyFormat = MailFormat.Text;
    } // 设置为高级优先权
    mailObj.Priority = MailPriority.High; mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); 
    mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this._MailFrom);
    mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this._MailFromPwd);
    // 为邮件添加附件
    // 注意:这里我们创建了一个mailattachment对象添加一个附件到邮件中,我们暂时不需要发送附件
    //mailObj.Attachments.Add(new MailAttachment("c:\\test.doc")); // 使用SmtpMail对象发送邮件
    SmtpMail.SmtpServer = this._MailSmtpServer;
    SmtpMail.Send(mailObj);
    }