Hello Friends....
Welcome to this Blog...This Blog is specially for the .Net Developers where all developers can discuss the .Net and Sql Articles.
"And will you succeed? Yes! You will indeed!(98 and 3/4 percent guaranteed)."

Wednesday, November 10, 2010

Registration and Email Verification for New Accounts

In This Code i am Providing the code by which the user can easily registered to the Website and the E-Mail is sent to the user for the Verification. If the user will not verify his/her email,the account is not activated and that person cannot login.

Here are the Following Steps to achieve that:-

1.Create new Web application and make one form in which the user can register and add the following code to the source code:

      //Send email to user for verifying account
        CreateUserWizard cuw = (CreateUserWizard)sender;
        MembershipUser user = Membership.GetUser(cuw.UserName);
        Guid userId = (Guid)user.ProviderUserKey;
        System.Net.Mail.MailMessage EmailMsg = new          System.Net.Mail.MailMessage("info@ask.com",            
        EmailMsg.Subject = "Email Verification fromhttp:dinesh-itsolutions.blogspot.com/";
        EmailMsg.IsBodyHtml = true;
        EmailMsg.Body = "Thanks for registering with www.http://dinesh-itsolutions.blogspot.com/!<br /><br />Your activation link : <a href=http://http://dinesh-itsolutions.blogspot.com/?ID=" + userId.ToString() + ">Link</a>.";
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
        //This object stores the authentication values
        System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("smtpserverinfo", "smtpserverpassword");

        mailClient.Host = "mail.ask.com";
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = basicAuthenticationInfo;

2.By the code the email is sent to the user with the unique link.

3.When the user check his/her mail and click on the activate link then it will redirected to the new webpage

now retrieve that unique id from the URL.

4.After Retrieving the Id'...just set the stutus of the Client from 0 to 1 in the database so that the person can login.        

Thank You:

Enjoy ....................n in case if any query then ask me......


  1. nice work..hey thanx for coding.

  2. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial, Ms sql server

    Thanks a lot..!