using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Net; using System.Net.Mail; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace infoExpediters { public partial class contactus : System.Web.UI.Page { string contact; protected void Page_Load(object sender, EventArgs e) { } // send a mail to service@infoexpediters.com protected void btnsubmit_Click1(object sender, EventArgs e) { if (rbtnemail.Checked) { contact = "mail"; } if (rbtnphone.Checked) { contact = "phone"; } try { System.Net.Mail.MailMessage ms = new System.Net.Mail.MailMessage(); System.Net.Mail.SmtpClient smtp = new SmtpClient(); MailAddress FromAdd = new MailAddress("service@infoexpediters.com"); ms.From = FromAdd; ms.To.Add("service@infoexpediters.com"); ms.Subject = "Contact us"; ms.IsBodyHtml = false; ms.Body = "E-Mail: " + txtemail.Text + Environment.NewLine + "First Name: " + txtfirstname.Text + Environment.NewLine + "Last Name: " + txtlastname.Text + Environment.NewLine + "Company Name: " + txtcompanyname.Text + Environment.NewLine + "Phone Number: " + txtphone.Text + Environment.NewLine + "Contact Preference: " + contact + Environment.NewLine + "Message: " + textarea.Text + Environment.NewLine + "From: " + Environment.NewLine + txtemail.Text; smtp.Credentials = new NetworkCredential("service@infoexpediters.com", "service123"); smtp.Host = "relay-hosting.secureserver.net"; smtp.Send(ms); TextClear(); Response.Redirect("Message.aspx",false); } catch (Exception ex) { Label1.Text = "Message failed "; } } // Clear all form fields public void TextClear() { Label1.Text = ""; txtfirstname.Text = ""; txtlastname.Text = ""; txtemail.Text = ""; txtcompanyname.Text = ""; txtphone.Text = ""; textarea.Text = ""; rbtnemail.Checked = false; rbtnphone.Checked = false; } } }