protected void btSubmit_Click(object sender, EventArgs e)
{
try
{
SmtpClient smtpClient = new SmtpClient();
MailMessage objMail = new MailMessage();
//From Address will be assigned from the e-mail specified in the From TextField You can also give the code given below. MailAddress objMail_fromaddress = new MailAddress(txtMail.Text);
MailAddress objMail_toaddress = new MailAddress("mymail@gmail.com");
objMail.IsBodyHtml = true;
//Assigning From address to the MailMessage class objMail.From = objMail_fromaddress;
//Assigning To address to the MailMessage class as a collection objMail.To.Add(objMail_toaddress);
objMail.Subject = "Feedback from" + txtName.Text + " to us from Contact us Form";
objMail.Body = "Message from" + txtName.Text + "as comments:-" + txtComments.Text + "<br><br><br>" + "Address:" + txtAddress.Text + "<br>Mobile no:" + txtTel.Text;
objMail.Priority = MailPriority.High;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587
smtpClient.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "1239807643");
smtpClient.EnableSsl = true;
smtpClient.Send(objMail);
Label1.Visible = true;
Label1.Text = "your feedback is submitted successfully.";
}
catch (Exception ex)
{
Label1.Visible = true;
Label1.Text = "something went wrong!, Please Try Again." + ex.Message;Monday, February 21, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment