-
Notifications
You must be signed in to change notification settings - Fork 0
/
.csharp
74 lines (64 loc) · 2.79 KB
/
.csharp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// How to send activation link after registration done in asp.net application by Using C# Coding
// to see whole project with source code go through this link http://allittechnologies.blogspot.in/2015/04/how-to-send-user-confirmation-email-after-registration-in-asp-net-csharp-codeing.html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;
using System.Net.Mail;
public partial class Registration : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RCCon"].ConnectionString);
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
// Send Email to user email address
public void Send_Account_Activation_Link(string emailaddress, string act_code)
{
MailMessage mm = new MailMessage("Your EMail ID", emailaddress);
mm.Subject = "Account Activation";
string body = "Hello " + txtusername.Text + ",";
body += "
Please click the following link to activate your account
";
body += "
<a style="background:#000000; color:#fafafa; padding:10px 100px 10px 100px; width:350px; text-decoration:none; font-weight:bold; font-size:20px;" href=""+ Request.Url.AbsoluteUri.Replace("Registration.aspx", "Account_Activation.aspx?ActivationCode=" + act_code) + "">Click here to activate your account.</a>";
body += "
Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.Credentials = new System.Net.NetworkCredential("Your Email ID", "<your email="" password="">");
smtp.EnableSsl = true;
smtp.Send(mm);
}
protected void Btn_Register_Click(object sender, EventArgs e)
{
string activationCode = Guid.NewGuid().ToString();
string encry_password = Encrypt_Password(txtpassword.Text);
cmd = new SqlCommand("insert into Registration values('" + txtusername.Text.ToLower() + "','" + encry_password + "','" + txtemailid.Text + "','" + activationCode + "','inactive')");
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
Send_Account_Activation_Link(txtemailid.Text, activationCode);
con.Close();
Session["user"] = txtusername.Text;
Response.Redirect("Account_Activation.aspx");
}
private string Encrypt_Password(string password)
{
string pwdstring = string.Empty;
byte[] pwd_encode = new byte[password.Length];
pwd_encode = Encoding.UTF8.GetBytes(password);
pwdstring = Convert.ToBase64String(pwd_encode);
return pwdstring;
}
}
</your>