private void SendEmails(object sender, System.Timers.ElapsedEventArgs args)
        {
            if (Connection != null) {

                if (Connection.open()) {
                    List<int> ids = new List<int>();

                    // Get a list of all emails past the window time
                    DateTime cutoff = DateTime.Now.AddHours(-GetSendWindowHours());

                    string sql = string.Format("select id from mail_send where status={0} and date_created < '{1}';",
                        (int)BusinessLayer.Enums.MailStatus.WAITING, cutoff.ToString("yyyy-MM-dd HH:mm:ss"));
                    using (DbDataReader reader = Connection.getDataReader(sql)) {

                        while (reader.Read()) {
                            ids.Add(int.Parse(reader["id"].ToString()));
                        }
                    }

                    // Create the mailsends from the ids
                    foreach (int id in ids) {
                        MailSend mail = new MailSend(id);
                        SendEmail(mail);

                        // Update mailsend item as sent
                        mail.Status = BusinessLayer.Enums.MailStatus.SENT;
                        mail.save();
                    }

                } else {
                    Console.WriteLine("Cannot connect to database.");
                }

            }
        }