How do I send an email confirmation link to the user

Saman Zia picture Saman Zia · Mar 20, 2011 · Viewed 9.7k times · Source

I am developing a website where I need to send confirmation link to the user's e-mail account when he/she signs-up.

When user clicks this link then a field userEnable in database changes from "false" to "true".

How do I send a confirmation e-mail to a user when user clicks on the signup button.

When user clicks on this confirmation link then how would the field UserEnable change from "false" to "true"

I am using asp.net 4.0 with VB.NET as the language and SQL Server 2008 for my database.

Answer

nemke picture nemke · Mar 20, 2011

First, you should create table User in database with a column like Active = false in database (1 bit database field type). Then, after user has created his account, you should send him an activation link with query string containing user activation guid. Something like:

Please activate your account at www.mysite.com?id=21EC2020-3AEA-1069-A2DD-08002B30309D

At confirmation page, you will check for this query like

var id = Response.QueryString["id"]
if (id!= null) userBL.ActivateUser(id);

ActivateUser() method would update field to true, and also send an email confirmation.