CreateUserWizard.OnSendMailError メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim e As SendMailErrorEventArgs Me.OnSendMailError(e)

OnSendMailError メソッドは、新規ユーザーに電子メールを送信する際に、SMTP メール システムが例外を発生させる場合に呼び出されます。
e パラメータとして渡された SendMailErrorEventArgs オブジェクトの Exception プロパティを調べて、例外の実際の原因を判断します。最も一般的な問題は、Web.config ファイルの <smtpMail> セクションの設定エラーです。
e パラメータとして渡された SendMailErrorEventArgs オブジェクトの Handled プロパティを設定して、OnSendMailError メソッドを呼び出す例外が処理されたことを通知する必要があります。そうしない場合、例外が再度スローされます。
イベントが発生すると、デリゲートを使用してイベント ハンドラが呼び出されます。詳細については、「イベントの処理と発生」を参照してください。 .
OnSendMailError メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理することもできます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
継承時の注意 派生クラスで OnSendMailError をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnSendMailError メソッドを必ず呼び出してください。
電子メール エラーをサイト固有のログ記録関数に記録するカスタム CreateUserWizard オブジェクトを定義するコード例を次に示します。
Imports System Imports System.Web Imports System.Web.UI.WebControls Imports System.Security.Permissions Namespace Samples.AspNet.VB.Controls <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public Class CustomCreateUserWizard Inherits CreateUserWizard Private Sub SiteSpecificErrorLoggingProcedure(ByVal e As SendMailErrorEventArgs) ' Site-specific code for logging e-mail errors goes here. End Sub Overloads Sub OnSendMailError(ByVal e As SendMailErrorEventArgs) Me.SiteSpecificErrorLoggingProcedure(e) e.Handled = True End Sub End Class End Namespace
using System; using System.Web; using System.Web.UI.WebControls; using System.Security.Permissions; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class CustomCreateUserWizard : CreateUserWizard { private void SiteSpecificErrorLoggingProcedure (SendMailErrorEventArgs e) { // Site-specific code for logging e-mail errors goes here. } protected override void OnSendMailError (SendMailErrorEventArgs e) { this.SiteSpecificErrorLoggingProcedure (e); e.Handled = true; } } }
CustomCreateUserWizard を使用した Web ページのデモを行うコード例を次に示します。
<%@ Page Language="VB"%> <%@ Import namespace="Samples.AspNet.VB.Controls" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim createUser As New CustomCreateUserWizard Placeholder1.Controls.Add(createUser) End Sub </script> <html> <head runat="server"> <title> CreateUserWizard.OnSendMailError sample</title> </head> <body> <form id="form1" runat="server"> <div> <asp:placeholder id="Placeholder1" runat="server"> </asp:placeholder> </div> </form> </body> </html>
<%@ Page Language="C#"%> <%@ Import namespace="Samples.AspNet.CS.Controls" %> <script runat="server"> void Page_Load (object sender, EventArgs e) { CustomCreateUserWizard createUser = new CustomCreateUserWizard (); Placeholder1.Controls.Add (createUser); } </script> <html> <head runat="server"> <title>CreateUserWizard.OnSendMailError sample</title> </head> <body> <form id="form1" runat="server"> <div> <asp:placeholder id="Placeholder1" runat="server"> </asp:placeholder> </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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CreateUserWizard.OnSendMailError メソッドのページへのリンク