try this one..
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(txtMailFrom.Text, txtMailTo.Text, txtSubject.Text, txtBody.Text);
/* In case of adding CC and BCC
MailAddress bcc = new MailAddress(txtBcc.Text);
MailAddress cc = new MailAddress(txtCC.Text);
mailMessage.Bcc.Add(bcc);
mailMessage.CC.Add(cc);
*/
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Send(mailMessage);
Response.Write("<script>alert('Mail Sent')</script>");
}
catch (Exception ex)
{
throw ex;
}
}
And in the Configuration file add this
<system.net>
<mailSettings>
<smtp>
<network host="" port="" userName="" password=""/>
</smtp>
</mailSettings>
</system.net>