Saturday, March 12, 2011 Email to Recover or Reset Password

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RecoverPassword.aspx.cs" Inherits="RecoverPassword" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">  
 <html xmlns="">  
 <head runat="server">  
   <title>Untitled Page</title>  
   <form id="form1" runat="server">  
    <h2>Recover Your Password</h2>  
     <asp:PasswordRecovery ID="RecoverPwd" runat="server"  
       <MailDefinition BodyFileName="~/PasswordRecovery.txt"  
         Subject="Your password has been reset...">  

 using System.Net.Mail;  
 using System.Net;  
 public partial class RecoverPassword : System.Web.UI.Page  
   protected void Page_Load(object sender, EventArgs e)  
     MailMessage myMessage = new MailMessage();  
     SmtpClient mySmtpClient = new SmtpClient();  
     myMessage.To.Add(new MailAddress(""));  
     mySmtpClient.Port = 587;  
     mySmtpClient.Credentials = new System.Net.NetworkCredential("admin emailid","password");  
     mySmtpClient.EnableSsl = true;  
   protected void RecoverPwd_SendingMail(object sender, MailMessageEventArgs e)  
     SmtpClient mySmtpClient = new SmtpClient();  
     mySmtpClient.EnableSsl = true;  
     e.Cancel = true;  

you can also use text file to send email rather than using html.using html make email message good in look but in text thats not avalable.
 Your password has been reset, <%UserName%>!  
 According to our records, you have requested that your password be reset. Your new password is: <%Password%>  
 If you have any questions or trouble logging on please contact a site administrator.  
 Thank you!  

IIS setting for smtp remain same as in Email to verify your a/c

No comments:

Popular Posts