SendMailErrorEventArgs.Handled Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates if the SMTP exception that is contained in the Exception property has been handled.
public:
property bool Handled { bool get(); void set(bool value); };
public bool Handled { get; set; }
member this.Handled : bool with get, set
Public Property Handled As Boolean
Property Value
If true
, the exception is consumed and handled by the SendMailErrorEventHandler delegate. If false
, the exception is rethrown, including the original call stack and error message.
The default is false
.
Remarks
The Handled property indicates if the Exception has been handled. The exception is raised by the SMTP mail provider when an email message cannot be sent by the ChangePassword control or the CreateUserWizard. The most common reason for the exception is a configuration error in the <smtp> Element (Network Settings) of the machine configuration file. Although an error like this is typically discovered during the development and debugging of an application, mail servers can fail unexpectedly in a production environment, and you must determine whether you want the entire application to fail in that situation. If not, handling the event allows your application to proceed.
If you do not create an event handler for the SendMailError event, or if you create an event handler but leave the Handled property set to false
, your Web application will stop running if an error occurs when sending an email message, and ASP.NET will display an error message. Handling the event allows your Web application to continue to run even though an exception has occurred. This is useful when it is not critical to send an email message. For example, if the exception occurs when a user is working through a multi-step wizard, it can be advantageous to log the error, display an informative message to the user, and allow the user to complete the wizard.