PasswordRecovery.OnSendMailError(SendMailErrorEventArgs) 方法

定义

当无法向用户发送电子邮件时引发 SendMailError 事件。Raises the SendMailError event when an email message cannot be sent to the user.

protected:
 virtual void OnSendMailError(System::Web::UI::WebControls::SendMailErrorEventArgs ^ e);
protected virtual void OnSendMailError (System.Web.UI.WebControls.SendMailErrorEventArgs e);
abstract member OnSendMailError : System.Web.UI.WebControls.SendMailErrorEventArgs -> unit
override this.OnSendMailError : System.Web.UI.WebControls.SendMailErrorEventArgs -> unit
Protected Overridable Sub OnSendMailError (e As SendMailErrorEventArgs)

参数

e
SendMailErrorEventArgs

包含事件数据的 SendMailErrorEventArgsA SendMailErrorEventArgs that contains the event data.

注解

OnSendMailError当 SMTP 邮件服务引发异常时,将调用方法。The OnSendMailError method is called when the SMTP Mail service throws an exception. 默认实现将引发 SendMailError 错误,并且如果未处理异常,则会在保持调用堆栈的同时再次引发异常。The default implementation raises the SendMailError error and, if the exception is not handled, rethrows the exception while maintaining the call stack.

检查 Exception SendMailErrorEventArgs 作为参数传递的对象的属性 e ,以确定异常的实际原因。Examine the Exception property of the SendMailErrorEventArgs object passed as the e parameter to determine the actual cause of the exception. 在开发期间,引发事件的最常见原因 SendMailError<smtpMail> Web.config 文件的部分不正确。During development, the most common reason that the SendMailError event is raised is that the <smtpMail> section of the Web.config file is incorrect. 部署之后,此事件可能会出于多种原因而发生,这与电子邮件地址中的错误最为重要。After deployment, this event can occur for a variety of reasons, most having to do with errors in an email address.

必须将 Handled 作为参数传递的对象的属性设置 e 为, true 以指示已处理异常; 否则,将再次引发异常。You must set the Handled property of the object passed as the e parameter to true to signal that the exception has been handled; otherwise, the exception is thrown again.

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 ASP.NET Web Forms Pages 中的服务器事件处理For more information, see Server Event Handling in ASP.NET Web Forms Pages.

OnSendMailError 方法还允许派生类对事件进行处理而不必附加委托。The OnSendMailError method also allows derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.

继承者说明

当在 OnSendMailError(SendMailErrorEventArgs) 派生类中重写方法时,请确保调用 OnSendMailError(SendMailErrorEventArgs) 基类的方法,以便注册的委托接收事件。When overriding the OnSendMailError(SendMailErrorEventArgs) method in a derived class, be sure to call the OnSendMailError(SendMailErrorEventArgs) method for the base class so that registered delegates receive the event.

适用于

另请参阅