注册电子邮件通知

 发送两种类型的注册电子邮件通知

 

1.自动生成新密码并将改密码发送给进行注册的用户

 

CreateUserWizardPasswordConfirmation.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateUserWizardPasswordConfirmation.aspx.cs" Inherits="CreateUserWizardPasswordConfirmation" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CreateUserWizardPasswordConfirmation</title> </head> <body> <form id="form1" runat="server"> <div> <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" CompleteSuccessText="A Confirmation email containing you new password has sent to your email adress" AutoGeneratePassword="true" LoginCreatedUser="false" ContinueDestinationPageUrl="~/Login.aspx"> <MailDefinition From="Admin@YourSite.com" BodyFileName="PasswordConfirmation.htm" IsBodyHtml="true" Subject="Registration Confirmation"> </MailDefinition> <WizardSteps> <asp:CreateUserWizardStep runat="server" /> <asp:CompleteWizardStep runat="server" /> </WizardSteps> </asp:CreateUserWizard> </div> </form> </body> </html>

 

PasswordConfirmation.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Password Confirmation</title> </head> <body> Your new Password IS <%Password%> </body> </html>

 

 

 

2.让用户自己输入密码,然后在电子邮件的确认通知中发送特别的认证码。

 

CreateUserWizardCodeConfirmation.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateUserWizardCodeConfirmation.aspx.cs" Inherits="CreateUserWizardCodeConfirmation" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <mce:script runat="server"><!-- protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e) { MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName); string code = user.ProviderUserKey.ToString(); e.Message.Body = e.Message.Body.Replace("<%CodeConfirmation%>", code); } // --></mce:script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CreateUserWizardCodeConfirmation</title> </head> <body> <form id="form1" runat="server"> <div> <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" CompleteSuccessText="A Confirmation email containing you new password has sent to your email adress" DisableCreatedUser="true" ContinueDestinationPageUrl="ConfirmCode.aspx" OnSendingMail="CreateUserWizard1_SendingMail"> <MailDefinition From="Admin@YourSite.com" BodyFileName="CodeConfirmation.htm" Subject="Registration confirmation" IsBodyHtml="true"> </MailDefinition> <WizardSteps> <asp:CreateUserWizardStep runat="server" /> <asp:CompleteWizardStep runat="server" /> </WizardSteps> </asp:CreateUserWizard> </div> </form> </body> </html>

 

ConfirmationCode.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ConfirmCode.aspx.cs" Inherits="ConfirmCode" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <mce:script runat="server"><!-- protected void btnConfirm_Click(Object sender,EventArgs e) { MembershipUser user = Membership.GetUser(txtUserName.Text); if (user == null) { lblError.Text = "Invalid User Name"; } else { string providerCode = user.ProviderUserKey.ToString(); string userCode = txtConfirmationCode.Text.Trim(); if (providerCode != userCode) { lblError.Text = "Invalid Confirmation Code"; } else { user.IsApproved = true; Membership.UpdateUser(user); Response.Redirect("~/Secret/Default.aspx"); } } } // --></mce:script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Confirm Code</title> </head> <body> <form id="form1" runat="server"> <div> <p>Enter your</p> <asp:Label ID="lblError" EnableViewState="false" ForeColor="Red" runat="server" Text="Label"></asp:Label> <br /> <br /> <asp:Label ID="UserName" runat="server" Text="UserName" AssociatedControlID="txtUserName"></asp:Label> <br /> <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> <br /> <asp:Label ID="lblConfirmationCode" Text="Confirmation Code" AssociatedControlID="txtConfirmationCode" runat="server"></asp:Label> <br /> <asp:TextBox ID="txtConfirmationCode" runat="server"></asp:TextBox> <asp:Button ID="btnConfirm" Text="Confirm" OnClick="btnConfirm_Click" runat="server" /> </div> </form> </body> </html>

 

CodeConfirmation.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Code Confirmation</title> </head> <body> <%UserName %> your confirmation code is <%CodeConfirmation%> </body> </html>

 

 

 

只有<%Password%>和<%UserName%>可以直接用,其他的则必须写代码。

 

CreateUserWizard的几个属性AutoGeneratePassword,DisableCreatedUser,LoginCreateUser.

转载于:https://www.cnblogs.com/javaTest/archive/2010/05/21/2589535.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值