using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; public partial class Contact_Us : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { try { sendmail(); Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('Query sent successfully.');</script>"); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; } catch(Exception) { } } void sendmail() { string mail_text = TextBox3.Text + "\n\nFrom: " + TextBox1.Text + "\n\nE-Mail: " + TextBox2.Text; MailMessage message = new MailMessage("id@gmail.com", "id@gmail.com", TextBox4.Text, mail_text); SmtpClient clnt = new SmtpClient(); clnt.Port = 587; clnt.Host = "smtp.gmail.com"; clnt.Credentials = new System.Net.NetworkCredential("id@gmail.com", "password"); clnt.EnableSsl = true; clnt.Send(message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)