Hi,
write this code in button click:
var fromAddress = "Gmail@gmail.com";{u can take from address from web.config file also}
var toAddress = txtmailid.Text.ToString();
string subject = txtSubject.Text.ToString();
string body = "From: " + txtName.Text + "\n";
body += "Email Id: " + txtmailid.Text + "\n";
body += "Subject: " + txtSubject.Text + "\n";
body += "Query: \n" + txtQuery.Text + "\n";
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); smtp.Timeout = 20000;
}
smtp.Send(fromAddress, toAddress, subject, body);
Try this way.
Thank you,
SRILATHA
.Net Developer
Kondapallisrinivas, if this helps please login to Mark As Answer. | Alert Moderator