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
<asp:CreateUserWizard OnSendMailError="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 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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft