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 smtpClient = new SmtpClient())
         {
             var credential = new NetworkCredential
             {
                 UserName = "******", 
                 Password = "******"  
             };
             smtpClient.Credentials = credential;   //was getting error fixed with
             smtpClient.Host = "smtp.gmail.com";   //security settings at the followig link https://www.google.com/settings/security/lesssecureapps and enable less secure apps
             smtpClient.Port = 587; 
             smtpClient.EnableSsl = true;
             await smtpClient.SendMailAsync(message);
             return RedirectToAction("Sent");
         }
     }
     return View(model);
 }
 public JsonResult GetData()
 {
     EmailFormModel efm = new EmailFormModel();
     efm.FromName = "MVC Site";
     efm.FromEmail = "*****@*****.**";
     efm.Subject = "From Server";
     return Json(efm, JsonRequestBehavior.AllowGet);
 }