Export (0) Print
Expand All

CreateUserWizard.SendMailError Event

Note: This event is new in the .NET Framework version 2.0.

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 SendMailErrorEventHandler SendMailError
/** @event */
public void add_SendMailError (SendMailErrorEventHandler value)

/** @event */
public void remove_SendMailError (SendMailErrorEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

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 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="C#"%>

<script runat="server">
  void SiteSpecificLoggingProcedure(SendMailErrorEventArgs e)
  {
    // Code to log e-mail error, e.Exception.ToString, goes here.
  }

  void Createuserwizard1_SendMailError (object sender, SendMailErrorEventArgs e)
  {
    SiteSpecificLoggingProcedure (e);
    e.Handled = true;
  }
</script>

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

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft