TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Karthik Ramachandran
NA
116
28.2k
MVC web application
Aug 5 2018 11:35 AM
[HttpPost]
public ActionResult Contact_us(MailModel mm)
{
//return View();
// validate captcha
if (Session["Captcha"] == null || Session["Captcha"].ToString() != mm.Captcha)
{
ModelState.AddModelError("Captcha", "Wrong value of sum, please try again.");
//dispay error and generate a new captcha
return View();
}
else
{
if (ModelState.IsValid)
{
SmtpClient objSMTP = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"].ToString());
objSMTP.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"].ToString(), ConfigurationManager.AppSettings["MailPassword"].ToString());
System.Net.Mail.MailMessage objMailMessage = new System.Net.Mail.MailMessage();
try
{
objMailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MailUserName"].ToString());
objMailMessage.Subject = "Enquiry received from the Website.";
objMailMessage.To.Add("
[email protected]
");
objMailMessage.Body = "<b> Name </b> : " + mm.Name + " " + mm.LastName + " <br/><br/> <b> Telephone No : </b>" + mm.Telephone + "<br/><br/><b>Email : </b>" + mm.Email + " <b>Enquiry : </b>" + mm.Message;
objMailMessage.Priority = System.Net.Mail.MailPriority.High;
objMailMessage.IsBodyHtml = true;
objSMTP.Send(objMailMessage);
//Response.Redirect("thankyou.aspx");
}
catch (Exception)
{
throw;
//MessageBox.Show("Message not sent : " + exp.Message);
}
return RedirectToAction("Thankyou");
}
return RedirectToAction("Thankyou");
}
}
Reply
Answers (
2
)
how to sum even numbers less than entry number ?
RDLC: How to convert nvarchar to double or int