protected void SendMail()
        {
            try
            {
                //create the mail message
                MailMessage myMail = new MailMessage();
                //set the addresses
                myMail.From = new MailAddress("[email protected]");
                myMail.To.Add( "[email protected]");
                //set the content
                myMail.Subject = "有短信未发送" + DateTime.Now.ToLongTimeString();
                myMail.Body = "有" + MyClass.Dlookup("select count(*) from sms where dirty = 1 and datediff(day,updatetime,getdate())>1") + "条短信未发出";
                //send the message
                SmtpClient smtp = new SmtpClient("mail.gn.com.cn");
                smtp.Credentials = new NetworkCredential("[email protected]", "51012345");
                smtp.Send(myMail);            }
            catch (Exception e)
            {
                lbMessage.Text = e.Message;
            }
        }为何出现了以上错误???

解决方案 »

  1.   

    应当是你的邮件服务器配置问题
    直接 给你一个类吧using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Mail;
    using System.Configuration;    public class SendMail
        {
            string emailname = ConfigurationManager.AppSettings["emailname"].ToString();
            string emailpwd = ConfigurationManager.AppSettings["emailpwd"].ToString();
            string host = ConfigurationManager.AppSettings["emailhost"].ToString();        public void SendMailTo(string from, string body)
            {
                try
                {
                    //mail服务器设置
                    SmtpClient mailserver = new SmtpClient();
                    mailserver.Host = host;
                    mailserver.Credentials = new System.Net.NetworkCredential(emailname, emailpwd);
                    mailserver.Timeout = 5000;
                    mailserver.EnableSsl = true;
                    //mail邮件设置
                    MailMessage mail = new MailMessage();
                    MailAddress mfrom = new MailAddress(emailname);
                    mail.From = mfrom;
                    mail.To.Add(from);
                    mail.Subject = "";
                    mail.SubjectEncoding = System.Text.Encoding.GetEncoding("GB2312");
                    mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
                    mail.IsBodyHtml = true;
                    mail.Body = "";
                    mailserver.Send(mail);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
      

  2.   


    是不是和451 MI:RBL 发信IP位于一个或多个RBL里。请参考http://www.rbls.org/关于RBL的相关信息。
    这个错误有关啊?
      

  3.   

    C#自带的邮件发送服务,本身是有很多缺陷的。你试试换个邮箱发送接收。同时,建议改用jmail吧……