public ActionResult Create(Article model) { try { using (var context = new SiteContainer()) { var cache = new Article { Date = model.Date, Published = model.Published }; context.AddToArticle(cache); var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang); if (lang != null) { CreateOrChangeContentLang(context, model, cache, lang); } var article = context.Article.First(c => c.Id == cache.Id); article.CurrentLang = CurrentLang.Id; if (model.SendToSubscribers) { using (var customerContext = new CustomerContainer()) { var activeSubscribers = customerContext.Subscriber.Where(s => s.Active).ToList(); foreach (var subscriber in activeSubscribers) { var emailStatus = MailHelper.CreateSendEmailStatusInstance(article.Id, subscriber.Id); customerContext.AddToSendEmailStatus(emailStatus); } customerContext.SaveChanges(); var newThread = new Thread(new ThreadStart(Listelli.Controllers.HomeController.ProcessSendEmail)); newThread.Start(); HttpContext.Application["mailSender"] = newThread; //string articleText = HttpUtility.HtmlDecode(article.Description) // .Replace("src=\"", "src=\"http://listelli.ua"); //List<MailAddress> addresses = new List<MailAddress>(); //foreach (var item in customerContext.Subscriber.Where(s => s.Active)) // addresses.Add(new MailAddress(item.Email)); //string subscribeEmailFrom = ConfigurationManager.AppSettings["subscribeEmailFrom"]; //var emailFrom = new MailAddress(subscribeEmailFrom, "Listelli"); //MailHelper.SendTemplateByPortions(emailFrom, addresses, article.Title, "Newsletter.htm", null, true, // articleText); } } return RedirectToAction("Articles", "Home", new { area = "" }); } } catch { return View(); } }