using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Net.Mail; using System.Text; public partial class contact : System.Web.UI.Page { protected string emailFormsFrom = ConfigurationManager.AppSettings["emailFormsFrom"].ToString(); protected string emailFormsTo = ConfigurationManager.AppSettings["emailFormsTo"].ToString(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Page.SetFocus(txtName); Master.NavType = "contact"; } } protected void btnSubmit_Click(object sender, EventArgs e) { string fromEmail = txtFromEmail.Text.Trim(); string msg = txtMessage.Text.Trim(); SendEmail(fromEmail, msg); } private void SendEmail(string fromEmail, string msg) { StringBuilder sbMsg = new StringBuilder(); sbMsg.Append("

You received this message from: " + fromEmail + "

"); if (msg.Length > 0) sbMsg.Append("

" + msg + "

"); sbMsg.Append("

This message was sent from the Summer Freedom Savings contact form at www.washington.org

"); string body = sbMsg.ToString(); MailMessage mm = new MailMessage(emailFormsFrom, emailFormsTo); MailAddress msgfromEmail = new MailAddress(fromEmail); mm.ReplyTo = msgfromEmail; mm.Subject = "Contact Submission"; mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Send(mm); Response.Redirect("contactConfirm.aspx"); } }