You are not Logged in
Would you like to Login or Register

Today is: Friday, 21 November, 2008
Check this months hot topics

Customise Password Recovery Email

The majority of web applications need some sort of authentication component, and ASP.Net's authenication is excellent and allows you all the functionality you would expect.

On a recent web application we were required to provide users with the facility to recover their password, and as you'd expect there is a PasswordRecovery component that you just drop on a page and it works.

Unfortunately the emails that resulted from the control were not as rich as the client required. i.e HTML and Plain text alternate views, the HTML alternate view also used linked resources so the mail arrives in your mailbox with all its images attached. No need to download the images.

After a little bit of thought it was easy to override the PasswordRecovery mails using the SendingMail event.

protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{

    string pwd = Membership.GetUser(PasswordRecovery1.UserName).GetPassword(PasswordRecovery1.Answer);

    ProfileCommon UserProfile = Profile.GetProfile(PasswordRecovery1.UserName);
       
    //  send custom email at this point..  insert custom mail here
        
    // cancel the component's email here
    e.Cancel = true;

}

This simple code allows you to override the component's standard email and extract the user's password. With this information you can then insert your own custom mail object and send the recovery information to the user using a template of your choice...

Job done.. Hope this helps you out

kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Paul Marshall Skype
Author : Paul Marshall
Published : Sunday, 30 March, 2008

A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2.0 patterns and practices and is always looking for better ways of doing things. I love the .net platform, and I find it to be the most productive toolset I have used to date.

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views