public ActionResult CargarMails(EmailsModel model) { String[] mails = model.Mails.ToString().Split('\n'); MAILING email = new MAILING(); foreach (var mail in mails) { email.email = mail; ctx.MAILING.Add(email); ctx.SaveChanges(); } return RedirectToAction("Mailing"); }
public void EnviarMails(EmailsModel model) { IQueryable<MAILING> listEmails = ctx.MAILING.Where(m => m.email != null).OrderByDescending(m => m.id).Take(10); List<string> listaMails = new List<string>(); foreach (var email in listEmails) { listaMails.Add(email.email.Trim()); ctx.MAILING.Remove(email); } ctx.SaveChanges(); EmailHelper.sendEmail(null, listaMails.ToArray<string>(), model.Subject.ToString(), model.Body.ToString()); // return RedirectToAction("Mailing"); }