ユーザーがasp.net c#での登録を完了したときに確認リンクを含む電子メールを送信する方法これは私のコードです.plzは、アカウントを作成するときにユーザーの電子メールで確認リンクを送信する方法を教えてください.....plzヘルプ. ...前もって感謝します
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);
// open the data connection.
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);
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("salvevishal9@gmail.com");
mail.To.Add(TextBoxEA.Text);
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//send the message
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);
}
}
}
}