CreateUserWizard.SendingMail Událost

Definice

Nastane před odesláním e-mailového potvrzení o vytvoření účtu uživateli.

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 

Event Type

Příklady

Následující příklad kódu používá SendingMail událost k úpravě e-mailové zprávy odesílané novým uživatelům. Tento příklad vyžaduje textový soubor s názvem MailFile.txt, který obsahuje následující text.

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>

Poznámky

Třída CreateUserWizard odešle e-mailovou zprávu s potvrzením, že byl vytvořen nový účet webu, když MailDefinition vlastnost definuje e-mailovou zprávu k odeslání.

Vzhledem k tomu, že e-mailová zpráva obsahuje pouze pole automatického nahrazení polí uživatelského jména a hesla, můžete událost použít SendingMail k úpravě e-mailové zprávy před jejím odesláním novému uživateli.

Další informace o zpracování událostí najdete v tématu Zpracování a vyvolávání událostí.

Platí pro

Viz také