在线发邮件.有问提!求就 我是哪里配置错了?
下面的带码有问提吗?]
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="c#" runat="server">
void sendMailTest()
{
int[] array=new int[9];
for(int intCounter=0;intCounter<=9;intCounter++)
{
array[intCounter]=intCounter;
Response.Write("The value of the counter is:"+intCounter+"<br>");
}
}
void Page_Error(object sender,EventArgs e)
{
string errorMessage="Error occurred"+Server.GetLastError();
Server.ClearError();
MailMessage newMail=new MailMessage();
newMail.From="chenxianping@sohu.com";
newMail.To="chenxianping@sohu.com";
newMail.Subject="Error Occurred";
newMail.Body=errorMessage;
SmtpMail.Send(newMail);
}
</script>
<%
sendMailTest();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
</body>
</html>
但结果却不正却.提示如下:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
与服务器的传输连接失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Runtime.InteropServices.COMException: 与服务器的传输连接失败。
源错误:
行 21: newMail.Subject="Error Occurred";
行 22: newMail.Body=errorMessage;
行 23: SmtpMail.Send(newMail);
行 24: }
行 25: </script>
源文件: D:\ASPNETTEMP\index.aspx 行: 23
堆栈跟踪:
[COMException (0x80040213): 与服务器的传输连接失败。
]
[TargetInvocationException: 调用的目标发生了异常。]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58
[HttpException (0x80004005): 未能访问“CDO.Message”对象。]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1840
System.Web.Mail.SmtpMail.Send(MailMessage message) +153
ASP.index_aspx.Page_Error(Object sender, EventArgs e) in D:\ASPNETTEMP\index.aspx:23
System.Web.UI.TemplateControl.OnError(EventArgs e) +109
System.Web.UI.Page.HandleError(Exception e) +68
System.Web.UI.Page.ProcessRequestMain() +2094
System.Web.UI.Page.ProcessRequest() +218
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
用原码也是同样的结果.我是哪里配置错了?
问题点数:0、回复次数:4Top
1 楼jasonlee0927(一颗心忘了收...)回复于 2004-09-04 20:59:23 得分 0
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=5138
應該對妳有幫助!Top
2 楼lovely_swallow(蓝色夏威夷)回复于 2004-09-04 21:07:34 得分 0
可能是验证没通过吧,试试这样呢:
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}
Top
3 楼chenxianping1979()回复于 2004-09-04 21:26:11 得分 0
都不好使.Top
4 楼lovely_swallow(蓝色夏威夷)回复于 2004-09-04 22:00:14 得分 0
错误信息?Top




