【发布时间】:2014-08-29 05:46:33
【问题描述】:
这是我的代码。我知道这是一个重复的问题,但我访问了 staqckoverflow 和 codeproject 中的所有链接,但仍然无法得到答案。
try
{
MailMessage mailmessage = new MailMessage();
mailmessage.To.Add("xxx.com");
mailmessage.From = new MailAddress("xxx.com");
mailmessage.Subject = "Transaction sent for Verification ";
mailmessage.Body = "Hello world,\n\nThis is an ASP.NET test e-mail!";
SmtpClient smtpClient = new SmtpClient(ConfigurationSettings.AppSettings["SmtpAdd"].ToString());
smtpClient.Send(mailmessage);
ClientScript.RegisterStartupScript(this.GetType(), "mailalert", "alert('" + "Mail sent for verification" + "');", true);
}
catch(Exception ex)
{
//Response.Write("Could not send E-mail- error: " + ex.Message);
ClientScript.RegisterStartupScript(this.GetType(), "mailfailure", "alert('" + ex.Message + "');", true);
}
【问题讨论】:
-
请发布错误跟踪。
-
错误信息是发送邮件失败。我的意思是异常消息
-
请检查内部异常。有很多潜在的原因(错误的 smtp、丢失的凭据等)
-
在 smtp 地址的某行显示 Java 异常错误。
-
正如克劳迪奥所说,请发布 InnerException 的实际文本。知道它在说什么真的很有帮助,“java”异常将是一个非常奇怪的异常。