CreateUserWizard.SendMailError Event


Occurs when there is an SMTP error sending e-mail to the new user.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Public Event SendMailError As SendMailErrorEventHandler

The SendMailError event is raised when there is a problem using the SMTP mail provider to send e-mail to the e-mail address provided by the new user. The most common reason to raise this event is when the <smtpMail> section of the Web.config file is incorrect.

The default SendMailError event handler does not catch or handle the SMTP error from the e-mail system. Your SendMailError event handler must set the Handled property of the SendMailErrorEventArgs object to true in order to stop the error from appearing to the Web site user.

For more information about handling events, see NIB: Consuming Events.

The following code example is a handler for the SendMailError event that calls a site-specific procedure to log the e-mail error. The Handled property of the SendMailErrorEventArgs object is set to true to indicate that the error has been handled.

<%@ page language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">
  Sub SiteSpecificLoggingProcedure(ByVal e As SendMailErrorEventArgs)
    'Code to log e-mail error, e.Exception.ToString, goes here.
  End Sub

  Sub Createuserwizard1_SendMailError1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SendMailErrorEventArgs)
    e.Handled = True
  End Sub

<html xmlns="" >
<head runat="server">
    <title>CreateUserWizard.SendMailError sample</title>
    <form id="form1" runat="server">
      <asp:createuserwizard id="Createuserwizard1" runat="server" 

.NET Framework
Available since 2.0
Return to top