Hello forum,
I have a link that is sent to user's email so that when user click on this link in his email, it will redirect user to the web page. But i want to use button instead. I also want the button to have my own custom design like background color. here is the line of code where the link is sent to the email
Here is my event that sends the activation link to email. But instead of activation link; I want to send activation button and link it to redirect to activation page
private void SendActivationEmail(int Uid)
{
string activationCode = Guid.NewGuid().ToString();
using (SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO UserActivation VALUES(@Uid, @ActivationCode)"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Uid", Uid);
cmd.Parameters.AddWithValue("@ActivationCode", activationCode);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
using (MailMessage mm = new MailMessage("georgeakpan13@gmail.com", mailtxtbx.Text))
{
mm.Subject = "Account Activation";
string body = "Hello " + txtname.Text.Trim() + ",";
body += "<br /><br />Please click the following link to activate your account";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("CS.aspx", "CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";
body += "Click here to activate your account.";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient SMTP = new SmtpClient("smtp.gmail.com", 587);
SMTP.UseDefaultCredentials = false;
SMTP.Credentials = new NetworkCredential("sender@gmail.com", "<password>");
SMTP.Send(mm);
}
}