The requested page is not available for the requested platform. You are viewing the content for Default platform.

ErrorHandling.CustomSendMailMessage Event

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

Namespace: DevExpress.ExpressApp.Web

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


public static event EventHandler<CustomSendMailMessageEventArgs> CustomSendMailMessage
Public Shared Event CustomSendMailMessage As EventHandler(Of CustomSendMailMessageEventArgs)

Event Data

The CustomSendMailMessage event handler receives an argument of the CustomSendMailMessageEventArgs type. 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.
ErrorId Gets the identifier of the error that occurred.
ErrorText Gets the text of the error message.
Exception Gets the exception that occurred.
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.
MessageSubject Gets the subject of the error notification message.
Smtp Gets an SmtpClient providing the ability to send e-mail by using the Simple Mail Transfer Protocol (SMTP).


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 and Mobile Applications). You can customize e-mailing options by subscribing to this event in the ASP.NET 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