public async Task <ActionResult> Contact(email_model model) { if (ModelState.IsValid) { try { var body = "<p>Email From:<bold>{0}({1})</p><p>Message:</p><p>{2}</p>"; var from = "CoreBlog<*****@*****.**>"; model.Body = "this is a message from your Blog site. The name and the email of the contacting person is above." + model.Body; var email = new MailMessage(from, WebConfigurationManager.AppSettings["emailto"]) { Subject = model.Subject, Body = string.Format(body, model.FromName, model.FromEmail, model.Body), IsBodyHtml = true }; var svc = new PersonalEmail(); await svc.SendAsync(email); return(View(new email_model())); } catch (Exception ex) { Console.WriteLine(ex.Message); await Task.FromResult(0); } } return(View(model)); }
//httpget public ActionResult Contact() { email_model model = new email_model(); return(View(model)); }