CreateUserWizard.SendMailError 事件

定义

在向新用户发送电子邮件的过程中出现 SMTP 错误时发生。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 

事件类型

SendMailErrorEventHandler

示例

下面的代码示例是一个 SendMailError 事件的处理程序,该事件调用特定于站点的过程来记录电子邮件错误。The following code example is a handler for the SendMailError event that calls a site-specific procedure to log the email error. Handled对象的属性 SendMailErrorEventArgs 设置为 true ,以指示已处理错误。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>

注解

SendMailError当使用 SMTP 邮件提供程序向新用户提供的电子邮件地址发送电子邮件时,将引发事件。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. 引发此事件的最常见原因是 <smtpMail> Web.config 文件的部分不正确。The most common reason to raise this event is when the <smtpMail> section of the Web.config file is incorrect.

默认 SendMailError 事件处理程序不会捕获或处理来自电子邮件系统的 SMTP 错误。The default SendMailError event handler does not catch or handle the SMTP error from the email system. SendMailError 的事件处理程序必须将 Handled 对象的属性设置 SendMailErrorEventArgs 为,以便 true 阻止向网站用户显示错误。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.

适用于

另请参阅