using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Net.Mail; using System.Net; using System.Data.SqlClient; using System.Xml.Linq; public partial class contact : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["msg"] != null && Session["msg"] != "") { string strSes = Session["msg"].ToString(); if (strSes == "1") { lblSuccess.Visible = true; lblSuccess.Text = "Your enquiry sent successfully. Thank you for enquiry."; lblSuccess.Attributes.Add("style", "display: block;;"); } else { lblError.Visible = true; lblError.Text = "Your enquiry not sent. Please try again letter."; lblError.Attributes.Add("style", "display: block;;"); } Session["msg"] = null; } } protected void btnSend_Click(object sender, EventArgs e) { Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim()); if (Captcha1.UserValidated) { string strBody = "Hi

Contact Name: " + txtName.Text + "

Contact Email: " + txtEmail.Text + "

Phone no: " + txtPhone.Text + "

Contact Message : " + txtMessage.Text + "


Thanks
" + txtName.Text; int intRetrunValue = MailSending("info@visionsoftware.co.in", "Vision Software Enquiry", strBody); if (intRetrunValue == 1) { Session["msg"] = "1"; Response.Redirect("~/contact.aspx"); } else { lblError.Visible = true; lblError.Text = "Your enquiry not sent. Please try again letter."; lblError.Attributes.Add("style", "display: block;;"); } } else { lblError.Visible = true; lblError.Text = "Invalid captcha code."; lblError.Attributes.Add("style", "display: block;;"); } } public int MailSending(string strTo, string strSubject, string strBody) { string strFrom = "alpesh.atlas@gmail.com", strPassword = "qunthgbvgacmbarn", strHost = "smtp.gmail.com"; int intPort = 25; int intReturnValue = 0; MailMessage Mail = new MailMessage(); Mail.To.Add(new MailAddress("info@visionsoftware.co.in")); Mail.To.Add(new MailAddress("mayankmca.patel@gmail.com")); Mail.To.Add(new MailAddress("viradiyaav7@gmail.com")); Mail.From = new MailAddress(strFrom, "Vision Software Enquiry"); Mail.Subject = strSubject; Mail.Body = strBody; Mail.Priority = MailPriority.High; Mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.EnableSsl = true; smtp.Host = strHost; smtp.Port = intPort; smtp.Credentials = new System.Net.NetworkCredential(strFrom, strPassword); try { smtp.Send(Mail); intReturnValue = 1; } catch { } return intReturnValue; } }