CreateUserWizard.SendingMail 이벤트

정의

계정이 만들어진 경우 사용자에게 이메일 확인 메시지를 보내기 전에 발생합니다.

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

이벤트 유형

예제

다음 코드 예제에서는 이벤트를 사용하여 SendingMail 새 사용자에게 전송되는 전자 메일 메시지를 수정합니다. 이 예제에서는 다음 텍스트를 포함하는 MailFile.txt 라는 텍스트 파일이 필요합니다.

Your account was set up on our Web site with the following:

    Username:   <%UserName%>

To reset your password, you must answer the following question:

    Password Question: <%PasswordQuestion%>
    Password Answer:   <%PasswordAnswer%>

Thank you for creating an account with our Web site.
<%@ 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 Createuserwizard1_SendingMail(object sender, MailMessageEventArgs e)
  {
    // Set MailMessage fields.
    e.Message.IsBodyHtml = false;
    e.Message.Subject = "New user on Web site.";
    // Replace placeholder text in message body with information 
    // provided by the user.
    e.Message.Body = e.Message.Body.Replace("<%PasswordQuestion%>", Createuserwizard1.Question);
    e.Message.Body = e.Message.Body.Replace("<%PasswordAnswer%>",   Createuserwizard1.Answer);  
}
  
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      CreateUserWizard.MailDefinition sample</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:createuserwizard id="Createuserwizard1" runat="server" 
          maildefinition-bodyfilename="MailFile.txt"
          maildefinition-from="userAdmin@your.site.name.here" 
          onsendingmail="Createuserwizard1_SendingMail">
        </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 Createuserwizard1_SendingMail(ByVal sender As Object, ByVal e As MailMessageEventArgs)
    ' Set MailMessage fields.
    e.Message.IsBodyHtml = False
    e.Message.Subject = "New user on Web site."
    ' Replace placeholder text in message body with information 
    ' provided by the user.
   e.Message.Body = e.Message.Body.Replace("<%PasswordQuestion%>", Createuserwizard1.Question)
    e.Message.Body = e.Message.Body.Replace("<%PasswordAnswer%>",   Createuserwizard1.Answer)
  End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      CreateUserWizard.MailDefinition sample</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:createuserwizard id="Createuserwizard1" runat="server" 
          maildefinition-bodyfilename="MailFile.txt"
          maildefinition-from="userAdmin@your.site.name.here" 
          onsendingmail="Createuserwizard1_SendingMail">
        </asp:createuserwizard>
      </div>
    </form>
  </body>
</html>

설명

클래스는 CreateUserWizard 속성이 보낼 전자 메일 메시지를 정의할 때 MailDefinition 새 웹 사이트 계정이 만들어졌는지 확인하는 전자 메일 메시지를 보냅니다.

전자 메일 메시지에는 사용자 이름 및 암호 필드에 대한 자동 대체 필드만 있으므로 새 사용자에게 전송되기 전에 이벤트를 사용하여 SendingMail 전자 메일 메시지를 수정할 수 있습니다.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

적용 대상

추가 정보