Ejemplo n.º 1
0
        public static void SendMail(string clientname, string invoiceno, string senum, DateTime datesubmit, DateTime duedate)
        {
            var title         = $"{clientname} Invoice Due Notification";
            var start         = datesubmit;
            var end           = duedate;
            var servertime    = DateTime.Today;
            var countdowndate = end.AddDays(-2);

            //  if()
            if (servertime == countdowndate)
            {
                var message = $"Your Invoice Due Notification {invoiceno}  with Service Entry no: {senum} expires in 3 days";
                using (pdInvoiceEntities db = new pdInvoiceEntities())
                {
                    List <string> staffsemail = db.Staffs.Select(c => c.Email).ToList();
                    SendEmailNotif(title, message, staffsemail);
                }
            }
            else if (servertime == end)
            {
                var message = $"Your Invoice Due Notification {invoiceno}  with Service Entry no: {senum} expires Today";
                using (pdInvoiceEntities db = new pdInvoiceEntities())
                {
                    List <string> staffsemail = db.Staffs.Select(c => c.Email).ToList();
                    SendEmailNotif(title, message, staffsemail);
                }
            }
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     using (pdInvoiceEntities db = new pdInvoiceEntities())
     {
         var invoicesdate = db.Nairas.Select(c =>
                                             new InvoiceDate {
             ClientName = c.ClientName, InvoiceNum = c.InvoiceNumber, SeNumber = c.SENumber, DateSubmitted = c.DateSubmitted, DueDate = c.DueDate
         });
         foreach (var invoices in invoicesdate)
         {
             SendMail(invoices.ClientName, invoices.InvoiceNum, invoices.SeNumber, invoices.DateSubmitted, invoices.DueDate);
         }
     }
 }