ערוך

שתף באמצעות


CreateUserWizard.SendMailError Event

Definition

Occurs when there is an SMTP error sending email to the new user.

public:
 event System::Web::UI::WebControls::SendMailErrorEventHandler ^ SendMailError;
public event System.Web.UI.WebControls.SendMailErrorEventHandler SendMailError;
member this.SendMailError : System.Web.UI.WebControls.SendMailErrorEventHandler 
Public Custom Event SendMailError As SendMailErrorEventHandler 

Event Type

Examples

The following code example is a handler for the SendMailError event that calls a site-specific procedure to log the email 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 email 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>
<%@ page language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  Sub SiteSpecificLoggingProcedure(ByVal e As SendMailErrorEventArgs)
    'Code to log email error, e.Exception.ToString, goes here.
  End Sub
  
  Sub Createuserwizard1_SendMailError1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SendMailErrorEventArgs)
    SiteSpecificLoggingProcedure(e)
    e.Handled = True
  End Sub
</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_SendMailError1">
      </asp:createuserwizard>
    </div>
    </form>
</body>
</html>

Remarks

The SendMailError event is raised when there is a problem using the SMTP mail provider to send email to the email 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 email 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 how to handle events, see Handling and Raising Events.

Applies to

See also