ErrorHandling.CustomSendMailMessage Event

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

Namespace: DevExpress.ExpressApp.Web

Assembly: DevExpress.ExpressApp.Web.v18.2.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 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