Export (0) Print
Expand All

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

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

In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<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 Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft