Example #1
0
        public void SendEmail(string email, int ID_ORDER)
        {
            MailManager  mm  = new MailManager();
            StreamReader str = new StreamReader(Server.MapPath("~/Templates/NewOrder.html"));

            var body = str.ReadToEnd();

            List <ORDERS_ITEM> suppliesList = db.ORDERS_ITEM.Include(x => x.SUPPLIER_INSUMO).Include(x => x.ORDER).Where(x => x.ID_ORDER == ID_ORDER).ToList();

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("<tr><th>CODE</th><th>DESCRIPTION</th><th>QUANTITY</th></tr>");
            foreach (ORDERS_ITEM ci in suppliesList)
            {
                strBuilder.AppendLine("<tr>");

                strBuilder.AppendLine("<td width='100'>");
                strBuilder.AppendLine(ci.SUPPLIER_INSUMO.INSUMO.NOMBRE);
                strBuilder.AppendLine("<td/>");

                strBuilder.AppendLine("<td align='left' width='500'>");
                strBuilder.AppendLine(ci.SUPPLIER_INSUMO.INSUMO.NOMBRE);
                strBuilder.AppendLine("<td/>");

                strBuilder.AppendLine("<td width='100'>");
                strBuilder.AppendLine(ci.QUANTITY.ToString());
                strBuilder.AppendLine("<td/>");

                strBuilder.AppendLine("</tr>");
            }
            body = body.Replace("#body#", strBuilder.ToString());
            mm.EnviarMail("Order from Pablos Kitchen", body, "*****@*****.**");
        }
Example #2
0
        public void SendEmail(string email, int id)
        {
            MailManager mm = new MailManager();

            CreatePDF(id);

            CATERING catering = db.CATERINGs.Where(x => x.ID_CATERING == id).FirstOrDefault();
            var      body     = "Please find attached the catering information.";

            SmtpClient smtpCliente = new SmtpClient();

            smtpCliente.Host                  = "relay-hosting.secureserver.net ";
            smtpCliente.Port                  = 25;
            smtpCliente.EnableSsl             = false;
            smtpCliente.UseDefaultCredentials = true;
            smtpCliente.Credentials           = new NetworkCredential {
                UserName = "******", Password = "******"
            };
            var mailMEssage = new MailMessage();

            mailMEssage.From    = new MailAddress("*****@*****.**", "Catering Order");
            mailMEssage.Subject = "NEW ORDER. SCHEDULED DATE: " + catering.EVENT_DATE.Value.ToShortDateString() + " from " + catering.CLIENT.NAME + " " + catering.CLIENT.SURNAME;
            mailMEssage.Body    = body;
            mailMEssage.To.Add(email);
            try
            {
                mailMEssage.Attachments.Add(new Attachment(Server.MapPath("~/Uploads/" + catering.CLIENT.NAME + "_" + catering.CLIENT.SURNAME + ".pdf")));
            }
            catch (Exception)
            {
                throw;
            }
            mailMEssage.IsBodyHtml = true;
            smtpCliente.Send(mailMEssage);
        }
Example #3
0
        public ActionResult Create([Bind(Include = "ID_ORDER,ID_SUPPLIER,ORDER_DATE,DELIVERED,IS_DRAFT,ACTIVE")] ORDER ORDER)
        {
            if (ModelState.IsValid)
            {
                db.Entry(ORDER).State = EntityState.Modified;
                db.SaveChanges();
                SendEmail("*****@*****.**", ORDER.ID_ORDER);
                return(RedirectToAction("Index"));
            }

            MailManager mm = new MailManager();


            ViewBag.ID_SUPPLIER = new SelectList(db.SUPPLIERs, "ID_SUPPLIER", "NAME", ORDER.ID_SUPPLIER);
            return(View(ORDER));
        }