I have a create a register form by that when anyone register their information send to their email ids.
Now i want in my login form a forget password link by which two
textboxes should there on for registered email or another username when
any one fill and click then their info should be send to their email id
like password or email
Loading
Lalit MPosted Dec 1, 2009, 11:12 PM
using System.Data.SqlClient;
using System.Net.Mail;
using System.Net.Mime;
protected void Button1_Click(object sender, EventArgs e)
{
ob.get_username = TextBox1.Text;
DataSet ds = us.password_fetch();
if (ds.Tables[0].Rows.Count != 0)
{
Label1.Text = ds.Tables[0].Rows[0]["username"].ToString();
Label2.Text = ds.Tables[0].Rows[0]["password"].ToString();
Label3.Text = ds.Tables[0].Rows[0]["mailid"].ToString();
}
try
{
SmtpClient smpclient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromaddress = new MailAddress("[email protected]", "");
smpclient.Host = "photo43";
smpclient.Port = 25;
message.From = fromaddress;
message.To.Add(TextBox2.Text);
message.Subject = "Retrieve Your Password";
message.IsBodyHtml = true; ;
string body = ("username=" + Label1.Text + " " + "password=" + Label2.Text + " " + "mailid=" + Label3.Text + " ");
message.Body = body;
smpclient.Send(message);
ScriptManager.RegisterStartupScript(this, this.GetType(), "dg", "", false);
}
catch (SmtpException ex)
{
}
}
catch (Exception ex)
{ }
}
OR
Also Try this code sample
using System.Net.Mail;//Add NameSpace above
MailMessage mail = new MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress("[email protected]");
mail.Subject = "Email using Gmail";
string Body = "Hello World" +
" ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("username", "password");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);