public ActionResult SendNotification(MailoutCompose notification) { if (ModelState.IsValid) { foreach (var item in notification.PersonId) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("NAME", cDal.GetPersonByPersonId(int.Parse(item)).Fname); param.Add("Message", notification.Body); string html = bgService.GetHtml(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["mxTemplatePath"] + "tmpDefault.html", param); var mxType = lookupDal.GetAllMailoutType().Where(x => x.Id == 6).FirstOrDefault(); string toEmail = cDal.GetPersonEmailByPersonId(int.Parse(item)).Where(x => x.Type.Id == 1).FirstOrDefault().Value; var q = mxDAL.PushNotification(cDal.GetPersonByPersonId(int.Parse(item)), param, mxType.Id, toEmail, html); var res = emailService.EmailBySMTP(toEmail, ConfigurationManager.AppSettings["SMTP_FROM"], html, notification.Subject != null ? notification.Subject : mxType.Subject); if (res.HasError) { sDal.LogMe("EMAILEXCEPTION", $"EMAIL EXCEPTION: {res.ErrorMessage}", int.Parse(item)); mxDAL.UpdateNotification(q.Id); } } return(RedirectToAction("ComposeEmail")); } return(RedirectToAction("ComposeEmail")); }
public ActionResult ComposeEmail() { MailoutCompose vModel = new MailoutCompose() { From = sm.UserSession.Person.PersonEmail.Where(x => x.Type.Id == 1).FirstOrDefault().Value }; vModel.People = new SelectList(cDal.GetPeople().Where(g => g.GroupId == null).OrderBy(x => x.Fname).ToList(), "Id", "Name"); return(View(vModel)); }