public async Task <ActionResult> SendEmail(EmailViewModel model) { //var id = HttpContext.User.Identity.GetUserId(); // model.FromName= HttpContext.User.Identity.GetUserName(); // model.FromEmail= await UserManager.GetEmailAsync(id); var isExist = IsEmailExist(model.ToEmail); //if (ModelState.IsValid) //{ //if (isExist == true) //{ var body = "<p>Email From: {0} ({1})</p><p>Subject:{2}</p><p>Message:</p><p>{3}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress(model.ToEmail)); // replace with valid value //if (!string.IsNullOrWhiteSpace(model.CC)) //{ // message.CC.Add(model.CC); //} //if (!string.IsNullOrEmpty(model.Bcc)) //{ // message.Bcc.Add(model.Bcc); //} message.From = new MailAddress(model.FromName, model.FromEmail); // replace with valid value message.Subject = model.Subject; message.Body = string.Format(body, model.FromName, model.FromEmail, model.Subject, model.Message); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { await smtp.SendMailAsync(message); EmailServices.Create(model); TempData["message"] = "Email Send Successfylly!!"; } //} //else { // TempData["message"] = "Email Not Found!!"; //} return(RedirectToAction("Index")); //} // return View("Index",model); }