protected void btnSubmit_Click(object sender, EventArgs e)
{
string mailbody = "";
mailbody = "Someone with the following details sent an enquiry for <b>Dream World Properties</b><br/>";
mailbody += "Name : <b>" + txtName.Text + "</b><br/>";
mailbody += "Contact No. : <b>" + txtMobile.Text + "</b><br/>";
mailbody += "Email : <b>" + txtEmail.Text + "</b><br/>";
mailbody += "City : <b> " + txtCity.Text + "</b><br/>";
if (txtMsg.Text.Length > 0)
mailbody += "Message : <b>" + txtMsg.Text + "</b><br/>";
else
mailbody += "Message : <b>No Message !</b>";
MailAddress MailTo = new MailAddress(ConfigurationManager.AppSettings["mailto"].ToString());
MailAddress MailFrom = new MailAddress(ConfigurationManager.AppSettings["mailfrom"].ToString());
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["smtphost"].ToString());
smtp.Port = 465;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("information@dreamworldproperties.in", "information123");
smtp.UseDefaultCredentials = true;
MailMessage message = new MailMessage(MailFrom, MailTo);
message.Subject = "Dream World Properties" + '(' + DateTime.Now.ToString() + ')';
message.Body = mailbody;
message.IsBodyHtml = true;
try
{
if (Session["CAPTCHA"].ToString().Equals(txtcapcha.Text))
{
InsertConatctUsFeedback();
lblcapcha.Text = "Thanks For Your Message!";
txtcapcha.Text = "";
smtp.Send(message);
clear();
}
else
{
lblcapcha.Text = "Wrong Input";
txtcapcha.Text = "";
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message.ToString();
}
finally
{
}
}
public string ipTracker()
{
string ip = "";
ip = HttpContext.Current.Request.ServerVariables.Get("HTTP_X_FORWARDED_FOR");
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
ip = ipRange[le];
}
else
{
ip = HttpContext.Current.Request.ServerVariables.Get("REMOTE_ADDR");
}
return ip.ToString();
}
---------------------------------------web config File-----------------------------------------------------
<appSettings>
<add key="ForLogin" value="Login.aspx"/>
<add key="mailto" value="sushant@nextgensolution.in"/>
<add key="mailfrom" value="information@dreamworldproperties.in"/>
<add key="mailpass" value="information123"/>
<add key="smtphost" value="smtp.gmail.com"/>
<add key="domainid" value="1"/>
<!--<add key="dbcon1" value="Data Source=**********.db.*********.hostedresource.com; Initial Catalog=*************; UID=**********; pwd='************';Min Pool Size=10;Max Pool Size=200;Connect Timeout=200;Load Balance Timeout=200;"/>-->
</appSettings>
----------------Error ----------------------------
Failure sending mail.
plz help
Sushat