public ActionResult DeleteConfirmed(string id) { TabPosta tabPosta = db.TabPosta.Find(id); db.TabPosta.Remove(tabPosta); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Codice,Descrizione,smtpServer,smtpServerPort,sendUsing,AutenticationType,SendUsername,SendPassword,Sender,NotificationTo,ReceiptTo")] TabPosta tabPosta) { if (ModelState.IsValid) { db.Entry(tabPosta).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tabPosta)); }
public async Task <ActionResult> SendMail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Posta_Prototipi posta_prototipi = db.Posta_Prototipi.Find(id); if (posta_prototipi == null) { return(HttpNotFound()); } TabPosta tabposta = db.TabPosta.Find(posta_prototipi.CodiceConn); if (tabposta == null) { return(HttpNotFound()); } // SEND MAIL var body = posta_prototipi.Message; var message = new MailMessage(); message.To.Add(new MailAddress(posta_prototipi.emailtest)); // replace with valid value message.From = new MailAddress(posta_prototipi.Sender); // replace with valid value message.Bcc.Add(new MailAddress(posta_prototipi.Sender)); message.Subject = posta_prototipi.Subject; message.Body = string.Format(body, posta_prototipi.Subject, posta_prototipi.Header, posta_prototipi.Message, posta_prototipi.Footer); message.IsBodyHtml = true; message.Sender = new MailAddress(posta_prototipi.Sender);; var smtp = new SmtpClient(); smtp.EnableSsl = true; var credential = new NetworkCredential { UserName = tabposta.SendUsername, Password = tabposta.SendPassword }; smtp.UseDefaultCredentials = false; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Credentials = credential; //smtp.Host = "smtp.gmail.com"; smtp.Host = tabposta.smtpServer; smtp.Port = (int)tabposta.smtpServerPort; await smtp.SendMailAsync(message); return(RedirectToAction("Edit", "Mailing", new { id = posta_prototipi.Codice })); }
// GET: TabPosta/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TabPosta tabPosta = db.TabPosta.Find(id); if (tabPosta == null) { return(HttpNotFound()); } return(View(tabPosta)); }
// POST: Mailing/SendMail/5 public JsonResult LongRunningProcess(int?id) { Posta_Prototipi posta_prototipi = db.Posta_Prototipi.Find(id); TabPosta tabposta = db.TabPosta.Find(posta_prototipi.CodiceConn); int itemsCount = posta_prototipi.Posta_Messaggi.Count(); foreach (var item in posta_prototipi.Posta_Messaggi) { var x = item.Nom; } for (int i = 0; i <= itemsCount; i++) { var body = posta_prototipi.Message; var message = new MailMessage(); // SEND MAIL message.To.Add(new MailAddress(posta_prototipi.emailtest)); // replace with valid value message.From = new MailAddress(posta_prototipi.Sender); // replace with valid value message.Bcc.Add(new MailAddress(posta_prototipi.Sender)); message.Subject = posta_prototipi.Subject; message.Body = string.Format(body, posta_prototipi.Subject, posta_prototipi.Header, posta_prototipi.Message, posta_prototipi.Footer); message.IsBodyHtml = true; message.Sender = new MailAddress(posta_prototipi.Sender);; var smtp = new SmtpClient(); smtp.EnableSsl = true; var credential = new NetworkCredential { UserName = tabposta.SendUsername, Password = tabposta.SendPassword }; smtp.UseDefaultCredentials = false; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Credentials = credential; //smtp.Host = "smtp.gmail.com"; smtp.Host = tabposta.smtpServer; smtp.Port = (int)tabposta.smtpServerPort; smtp.Send(message); //CALLING A FUNCTION THAT CALCULATES PERCENTAGE AND SENDS THE DATA TO THE CLIENT Functions.SendProgress("Process in progress...", i, itemsCount); } return(Json("", JsonRequestBehavior.AllowGet)); }