Skip to main content
.NET Framework 4.5.2+
  • The page you are viewing does not exist in the .NET 6.0+ platform documentation. This link will take you to the parent topic of the current section.

ErrorHandling.CustomSendMailMessage Event

Occurs before e-mailing the error alert to the application administrator.

Namespace: DevExpress.ExpressApp.Web

Assembly: DevExpress.ExpressApp.Web.v24.1.dll

NuGet Package: DevExpress.ExpressApp.Web

Declaration

public static event EventHandler<CustomSendMailMessageEventArgs> CustomSendMailMessage

Event Data

The CustomSendMailMessage event's data class is CustomSendMailMessageEventArgs. The following properties provide information specific to this event:

Property Description
ErrorDetails Gets the complete error description, including the request details, loaded assemblies, last trace entries, etc. Inherited from CustomSendErrorNotificationEventArgs.
ErrorId Gets the identifier of the error that occurred. Inherited from CustomSendErrorNotificationEventArgs.
ErrorText Gets the text of the error message. Inherited from CustomSendErrorNotificationEventArgs.
Exception Gets the exception that occurred. Inherited from CustomSendErrorNotificationEventArgs.
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
MailMessage Gets the error notification e-mail message.
MessageBody Gets the body of the error notification message. Inherited from CustomSendErrorNotificationEventArgs.
MessageSubject Gets the subject of the error notification message. Inherited from CustomSendErrorNotificationEventArgs.
Smtp Gets an SmtpClient providing the ability to send e-mail by using the Simple Mail Transfer Protocol (SMTP).

Remarks

The CustomSendMailMessage event is raised as a result of invoking the ErrorHandling.SendAlertToAdmin method, before sending the error message via SMTP to a recipient specified in the Web.config file (see Error Handling in ASP.NET Web Forms Applications). You can customize e-mailing options by subscribing to this event in the ASP.NET Web Forms application’s Application_Start method. Do not forget to unsubscribe from the CustomSendMailMessage in the Application_End method. The following snippet illustrates how to provide the SMTP credentials if authentication is required by the server, specified via the ErrorReportEmailServer key in the configuration file.

using System.Net;
// ...
protected void Application_Start(Object sender, EventArgs e) {
    ErrorHandling.CustomSendMailMessage += ErrorHandling_CustomSendMailMessage;
    // ...
}
private void ErrorHandling_CustomSendMailMessage(
    object sender, CustomSendMailMessageEventArgs e) {
    e.Smtp.UseDefaultCredentials = false;
    e.Smtp.Credentials = new NetworkCredential("username", "password");
}
protected void Application_End(Object sender, EventArgs e) {
    // ...
    ErrorHandling.CustomSendMailMessage-= ErrorHandling_CustomSendMailMessage;
}

Provide valid credentials instead of the “username” and “password” strings.

You can set the handler’s Handled parameter to true, to cancel sending the default notification.

If you want to use another notification mechanism (via instant messaging, etc.), or implement your own e-mailing procedure, handle the ErrorHandling.CustomSendErrorNotification event.

See Also