// Triggers when the timers wants to send emails
        static void SendEmails(EmailPriority priority)
        {
            List<EmailSendItem> items; // Emails to send
            if (priority == EmailPriority.Important)
                items = Library.Classes.EmailServer.EmailServer.PullPriorityItemsToSend(); // Get all important emails and send them
            else
                items = Library.Classes.EmailServer.EmailServer.PullItemsToSend(NumberOfNormalEmailToSendAtOnce); // Get the specific amount of normal emails

            //this is the broadcast message that sits at the bottom of the emails.
            string mess = Library.Classes.EmailServer.EmailServer.PullLatestEmailMessage();
            var property = new EmailProperty() { Key = "BROADCASTMESSAGE", Value = mess };

            if (items.Count == 0) return; // If no emails were found, do nothing

            logger.Info("Fetching emails, priority: " + priority.ToString());
            logger.Info(string.Format("{0} email(s) found", items.Count));
            var itemsToDelete = new List<int>(); // Keep track of sent emails and delete them afterwards
            foreach (var item in items)
            {
                try
                {
                    item.Properties.Add(property);
                    // Parse the email properties into the layout specified and get that as the email body
                    var body = ParseEmailIntoLayout(item.EmailLayout, item.Properties.ToList());
                    Email.SendEmail(item.Reciever, item.From, item.DisplayNameFrom, item.Subject, body); // Send the email
                    itemsToDelete.Add(item.EmailSendItemId); // Add to the delete list
                }
                catch (Exception e)
                {
                    logger.Info("Email send error", e);
                    ErrorDatabaseManager.AddException(e, e.GetType());

                }
            }
            Library.Classes.EmailServer.EmailServer.DeleteItems(itemsToDelete); // Delete all emails that has been sent
            logger.Info(string.Format("Finished, {0} email(s) sent", items.Count));
        }