问题引入:
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的,会不会是对方不允许这样搞?希望能有高人帮忙,分不够可以再加,先谢了:)
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的,会不会是对方不允许这样搞?希望能有高人帮忙,分不够可以再加,先谢了:)
解决方案 »
- 怎么让GridView添加一行数据完成后,默认选中那条数据啊?
- (新手)关于GridView 删除、编辑功能的代码实现
- 请教个问题,DropDownList控件OnSelectedIndexChanged事件后,如何保持url不变
- 再次争论,到底是用嵌入式SQL还是直接存储过程?
- 如何点击按钮自动关闭本窗体
- web开发中关于跟踪的两个问题请教
- 如何将Excel数据批量导入SQL数据库?
- 关于粘贴添加附件
- 一个asp.net2.0框架网站下建立一个.net1.1虚拟目录。虚拟目录无法访问
- 如不容易整了一VS。NET,导入里有OFFICE WEB COMPOENT 9.0,增FUNCTION,WIZARD,导哪一个
- 求 microsoft.net 2003 下载地址!
- 大哥大姐:急寻可以消除掉html语法的类或着方法。
用别人的服务器当然不放心啦。
大家都在推委责任,网管说是程序的问题(也可能是网络中心的问题)
程序员都说是网管的问题,唉,反正都不是自己的问题在这样的环境工作叫郁闷啊!没办法,请教高手帮忙吧