CreateUserWizard.SendingMail Event
.NET Framework 3.0
Occurs before the user is sent an e-mail confirmation that an account has been created.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public Event SendingMail As MailMessageEventHandler 'Usage Dim instance As CreateUserWizard Dim handler As MailMessageEventHandler AddHandler instance.SendingMail, handler
/** @event */ public void add_SendingMail (MailMessageEventHandler value) /** @event */ public void remove_SendingMail (MailMessageEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.
The CreateUserWizard class will send an e-mail message confirming that a new Web site account has been created when the MailDefinition property defines an e-mail message to send.
Because the e-mail message only has automatic replacement fields for the user name and password fields, you can use the SendingMail event to modify the e-mail message before it is sent to the new user.
For more information about handling events, see Consuming Events.
The following code example uses the SendingMail event to modify the e-mail message that is sent to new users. This example requires a text file named MailFile.txt that contains the following text.
<%@ 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>
<%@ 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>
Community Additions
ADD
Show: