Confirmation Email after Registration

Posted by Raj.Trivedi under ASP.NET on 10/5/2012 | Points: 10 | Views : 3328 | Status : [Member] [MVP] | Replies : 1
Hello Team,

I need to send confirmation email when a new user registers on the website with his username and password.

Regards,
Raj.Trivedi

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved



Responses

Posted by: Britsouls on: 10/7/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
try this.. u can send confirmation mail via gmail account.if any query feel free to ask.

protected void SendMail()
{
try
{
var fromAddress = "your@gmail.com";
// any address where the email will be sending
var toAddress = txtemail.Text;// this is member email address.
//Password of your gmail address
const string fromPassword = "password";
// Passing the values and make a email formate to display
string subject = txtcompany.Text;
string body = "From: " + txtname.Text + "\n";
body += "Email: " + txtemail.Text + "\n";
body += "Subject: " + txtlocation.Text + "\n";
// body += "Question: \n" + Comments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);

Panel3.Visible = false;
Panel4.Visible = true;
Label3.Text = "Email successfully sent.";
}
catch (Exception ex)
{
Panel3.Visible = false;
Panel4.Visible = true;
Label3.Text = "Send Email Failed.<br>" + ex.Message;
}
}

Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response