private static void SendEmail(DSModel db, EmailService email, NotificationModel notice)
        {
            try
            {
                string senderEmail = GLOB.Settings.Get<string>(20);
                string[] managementEmails = GLOB.Settings.Get<string>(21).Split(';');

                List<string> emailsToSend = new List<string>();
                if (notice.ReminderType == (uint)ReminderType.Driver || notice.ReminderType == (uint)ReminderType.MVR)
                    emailsToSend.Add(notice.Email);
                if (notice.ReminderType == (uint)ReminderType.Management || notice.ReminderType == (uint)ReminderType.MVR)
                    emailsToSend.AddRange(managementEmails);

                bool status = false;
                foreach (string address in emailsToSend)
                {
                    try
                    {
                        if (!email.SendEmail(senderEmail, address, notice.Message, notice.Message).Result.Failed)
                            status = true;
                    }
                    catch { }
                }

                NotificationRepository.UpdateNotificationStatus(db, notice, status);
            }
            catch { }
        }
        static void Main(string[] args)
        {
            DateTime checkDate = DateTime.Now.Date;

            string date = GetArg("CHECKDATE");
            if (!string.IsNullOrWhiteSpace(date))
            {
                checkDate = DateTime.ParseExact(date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }

            using (var db = DB.GetContext())
            {
                SMSService sms = new SMSService();
                EmailService email = new EmailService();
                var medicalNotifications = NotificationRepository.GetMedicalNotifications(db, checkDate);
                var licenseNotifications = NotificationRepository.GetLicenseNotifications(db, checkDate);

                //medicals
                foreach (var med in medicalNotifications)
                {
                    if (!string.IsNullOrWhiteSpace(med.CellPhone))
                        SendSMS(db, sms, med);
                    if (!string.IsNullOrWhiteSpace(med.Email))
                        SendEmail(db, email, med);
                }

                //licenses
                foreach (var lic in licenseNotifications)
                {
                    if (!string.IsNullOrWhiteSpace(lic.CellPhone))
                        SendSMS(db, sms, lic);
                    if (!string.IsNullOrWhiteSpace(lic.Email))
                        SendEmail(db, email, lic);
                }
            }
        }