问题引入:
x系统,回复客户的问题,利用SMTP回复邮件,并把回复的内容插如数据库。
实现不是很复杂,但是系统开始能正常运行,突然有一天就发生奇怪的问题:代码如下
private void reply_button_Click(object sender, System.EventArgs e)
{
sql="执行插入的语句"//没有问题
try
{
this.sendemail();
if(db.RunSQL(sql)=="OK")  //执行插入操作,正确返回“ok!”
{
Response.Write("<script>alert('回复添加成功!');location='question_reply.aspx?question_id="+this.question_id.ToString()+"';</script>");
Response.End();
}
else
{
Response.Write("操作错误!");
Response.End();
}
}
catch(Exception ex)
{
Response.Write(sql+ex.ToString());     Response.End();
}
}
//下面是发送邮件的方法
private void sendemail()
{
MailMessage mail=new MailMessage();
mail.To=user_email.Text.Trim();
mail.From="[email protected]";
mail.Subject="标题";
mail.BodyFormat=MailFormat.Html;
mail.Body="回复内容"
mail.Priority=MailPriority.High;

System.Web.Mail.SmtpMail.SmtpServer="smtp.163.com";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码"); //set your password here

try
{
System.Web.Mail.SmtpMail.Send(mail);
}
catch
{
throw;
}
}
结果问题是:
在我的电脑上开始测试时候发送正常,但是在服务器运行一短时间后

System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at psy_expert.Question_Reply.reply_button_Click(Object sender, EventArgs e)
比较郁闷,以前都没有这样的情况
在我的电脑上测试时候:
开始是这样的情况,但是后来
异常居然是
System.Web.HttpException: 未能访问“CDO.Message”对象。 ---> System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.Runtime.InteropServices.COMException (0x80040213): 与服务器的传输连接失败。分析:(1)可能是杀毒软件的问题(都是诺顿企业版),但是为什么系统运行了那么久才出现问题?(2)SMTP服务器问题,可是我刚接触,不是很了解那东西
(3)因为我们设的SMTP服务器是163的,会不会是对方不允许这样搞?希望能有高人帮忙,分不够可以再加,先谢了:)

解决方案 »

  1.   

    你能上网的话,就用自己的SMTP服务器吧。
    用别人的服务器当然不放心啦。
      

  2.   

    我也想用啊,但是内部的SMTP可以接收邮件,不可以发送邮件
    大家都在推委责任,网管说是程序的问题(也可能是网络中心的问题)
    程序员都说是网管的问题,唉,反正都不是自己的问题在这样的环境工作叫郁闷啊!没办法,请教高手帮忙吧