Example #1
0
        public JsonResult GetData()
        {
            EmailFormModel efm = new EmailFormModel();
            efm.FromName = "Kirstin";
            efm.FromEmail = "*****@*****.**";
            efm.Subject = "From Server";

            return Json(efm, JsonRequestBehavior.AllowGet);
        }
Example #2
0
 public async Task<ActionResult> Contact(EmailFormModel model)
 {
     if (ModelState.IsValid)
     {
         var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
         var message = new MailMessage();
         message.To.Add(new MailAddress("*****@*****.**"));
         message.From = new MailAddress(model.FromEmail);
         message.Subject = model.Subject;
         message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message);
         message.IsBodyHtml = true;
         using (var smtp = new SmtpClient())
         {
             await smtp.SendMailAsync(message);
             return RedirectToAction("Sent");
         }
     }
     return View(model);
 }