how to send email with verification link when user completes his registration in asp.net c# this is my code...plz tell me that how can i send verification link on users email when he create an account.....plz help....thanks in advance
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Linq;
using System.Xml.Linq;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Configuration;
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(
ConfigurationManager.ConnectionStrings["BMCConnectionString"].ConnectionString);
con.Open();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
Response.Write("<script>alert('Thanking you .....Registration Successful')</script>");
TextBoxDate.Text = DateTime.Now.ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMCConnectionString"].ConnectionString);
con.Open();
string insCmd = "insert into Registration(UserName, Password, RePassword, Email, FullName ,Date ,Month, Year, Gender, Area, Date1) values (@UserName, @Password, @RePassword, @Email, @FullName ,@Date ,@Month, @Year, @Gender, @Area, @Date1)";
SqlCommand insertUser = new SqlCommand(insCmd, con);
insertUser.Parameters.AddWithValue("@UserName", TextBoxUN.Text);
insertUser.Parameters.AddWithValue("@Password", TextBoxPW.Text);
insertUser.Parameters.AddWithValue("@RePassword", TextBoxRP.Text);
insertUser.Parameters.AddWithValue("@Email", TextBoxEA.Text);
insertUser.Parameters.AddWithValue("@FullName", TextBoxFN.Text);
insertUser.Parameters.AddWithValue("@Date", DropDownListDate.SelectedItem.Text);
insertUser.Parameters.AddWithValue("@Month", DropDownListMonth.SelectedItem.Text);
insertUser.Parameters.AddWithValue("@Year", DropDownListYear.SelectedItem.Text);
insertUser.Parameters.AddWithValue("@Gender", RadioButtonList1.SelectedItem.Text);
insertUser.Parameters.AddWithValue("@Area", DropDownListArea.SelectedItem.Text);
insertUser.Parameters.AddWithValue("@Date1", TextBoxDate.Text);
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("salvevishal9@gmail.com");
mail.To.Add(TextBoxEA.Text);
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Send(mail);
try
{
insertUser.ExecuteNonQuery();
con.Close();
}
catch (Exception er)
{
Response.Write(er);
}
}
}