C# 注册时向电子邮件发送确认邮件

C# 注册时向电子邮件发送确认邮件,c#,asp.net,email,login,C#,Asp.net,Email,Login,我想发送一封确认电子邮件给刚注册到该网站的用户。为了找到解决方案,我在谷歌上搜索了好几次,但到目前为止什么都没找到。。你能帮我查一下密码吗? 提前谢谢 using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; using System.Net.Mail; using System.Net; usin

我想发送一封确认电子邮件给刚注册到该网站的用户。为了找到解决方案,我在谷歌上搜索了好几次,但到目前为止什么都没找到。。你能帮我查一下密码吗? 提前谢谢

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Net.Mail;
using System.Net;
using System.Text;
using System.Data;

public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

    if (IsPostBack)
    {
        SqlConnection con = new     SqlConnection(ConfigurationManager.ConnectionStrings["RegisConnectionString"].ConnectionStr    ing);
        con.Open();
        string cmdStr = "Select count(*) from Table where Username='" +     TextBox1Username.Text + "'";
        SqlCommand userExist = new SqlCommand(cmdStr, con);
    /*  int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString());
        con.Close();
      if (temp == 1)
        {
            Response.Write("username already exists");
        } */
    }
}



protected void Submit_Click(object sender, EventArgs e)
{

    SqlConnection con = new     SqlConnection(ConfigurationManager.ConnectionStrings["RegisConnectionString"].ConnectionStr    ing);
    con.Open();
    string insCmd = "Insert into Register (Username, Password, EmailAddress,Fullname,     City) values (@Username, @Password, @EmailAddress, @Fullname, @City)";
    SqlCommand insertUser = new SqlCommand(insCmd, con);
    insertUser.Parameters.AddWithValue("@Username", TextBox1Username.Text);
    insertUser.Parameters.AddWithValue("@Password", TextBox2Password.Text);
    insertUser.Parameters.AddWithValue("@EmailAddress", TextBox4Email.Text);
    insertUser.Parameters.AddWithValue("@Fullname", TextBox5FullName.Text);
    insertUser.Parameters.AddWithValue("@City", TextBox6City.Text);
    {
        try
        {

                insertUser.ExecuteNonQuery();
                con.Close();
                Response.Redirect("Login.aspx");

        }
        catch (Exception er)
        {
            Response.Write("error: " + er.Message + " ,please try registering again");
        }

    }
}

我认为发送消息最简单的解决方案是通过ASP.NET邮件上的第一个Google链接。我想知道有什么对你不起作用:


我相信MailMessage的对象表示非常清楚,否则它完全是关于SMTP设置的。

该代码与发送电子邮件没有什么关系。你尝试了什么?发生了什么?我将根据你是“asp.net新手”的事实提出这个建议,所以我假设你还没有听说过。但是asp.net自带了自己的会员“系统”,这使得所有这些东西都很容易处理:由于你的问题没有集中在一个特定的编程问题上,我认为你现在不会得到更具建设性的建议。如果你真的在谷歌上搜索过,你会发现很多文章,这里有一个示例