不知道为什么,邮件会发不出去了.发邮件的代码是:
public static void SendMail(string to,string from,string subject,string body,bool isHtml)
{
string SmtpServer = System.Configuration.ConfigurationSettings.AppSettings["SmtpServer"];
string SmtpUserName = System.Configuration.ConfigurationSettings.AppSettings["SmtpUserName"];
string SmtpPassWord = System.Configuration.ConfigurationSettings.AppSettings["SmtpPassWord"];
System.Web.Mail.MailMessage Mail = new System.Web.Mail.MailMessage();
Mail.To = to;
Mail.From = from;
Mail.Subject = subject;
Mail.Body = body;
Mail.BodyFormat = (isHtml) ? System.Web.Mail.MailFormat.Html : System.Web.Mail.MailFormat.Text;
Mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
if (SmtpUserName != "" && SmtpPassWord != "")
{
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",SmtpUserName);
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",SmtpPassWord);
}
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
System.Web.Mail.SmtpMail.Send(Mail);
}产生的错误是:At least one of the From or Sender fields is required, and neither was found. 
指示为这行出错:System.Web.Mail.SmtpMail.Send(Mail);
以上出错是这样的,我在我的网站里做了一个像csdn的blog一样的程序,把浏览者的问题或意见发到作者邮箱.但奇怪的是:用Global.cs里的Application_Error事件中如下代码可以发去邮件,代码如下:
Exception error = Server.GetLastError().InnerException;
string body = "错误信息如下:";
body += "<br>1.异常详细信息:" + error.Message.ToString();
body += "<br>2.引发异常的方法:" + error.TargetSite.ToString();
body += "<br>3.堆栈跟踪:<br>" + error.StackTrace.ToString();
ChrisLiu.Component.Common.LogError(body);
调用的它:
public static void LogError(string content)
{
string From = "[email protected]";
string Subject = "网站错误报告邮件";
string Body = content;
Common.SendMail("[email protected]",From,Subject,Body,true);
}然后在邮件中显示为:
错误信息如下: 
1.异常详细信息:Could not access 'CDO.Message' object. 
.........郁闷~~~~~~~~~

解决方案 »

  1.   

    刚才在网上看了一下,原因的确很多,好象都试过了......没有解决:权限问题不太可能啊.因为在Global文件里可以发出去.
    无验证机制 的那种可能也试过,不行.
    设置 SMTP VIRTUAL SERVER 的 ACCESS中 RELAY 也试过,不行.
    我用瑞星杀毒软件和瑞星个人版防火墙,关了邮件发送监控啊.(只是防火墙怎么设置就不知道,它也没有提示.....)
      

  2.   

    CDO不好用,也不稳定,用jMail。
    搜一下资源挺多的。
      

  3.   

    测试一下,可以正常发送.我只把SmtpServer改成自己服务器.
      

  4.   

    是吗????感觉楼上各位兄弟的办法还是用JMail好点喔.......邮件发送类我自己有喔.好象......