public static EmailQueue CreateTicketOpdateretMail(Contact contact, string subject, int ticketNumber, string siteUrl, Bruger tekniker,  Task task)
        {
            var ticketUrl = $"{siteUrl.TrimEnd('/')}/ticket/edit/{ticketNumber}";

            var technician = tekniker != null ? tekniker.Bruger_Initialer : "(Ingen)";
            var taskStatus = (TaskStatus)(task.Task_Status ?? 0);

            string taskStatusText;
            switch (taskStatus)
            {
                case TaskStatus.NotStartet:
                    taskStatusText = "Endnu ikke påbegyndt";
                    break;
                case TaskStatus.WaitingFor:
                    taskStatusText = "Venter";
                    break;
                case TaskStatus.InProgress:
                    taskStatusText = "Under behandling";
                    break;
                case TaskStatus.Complete:
                    taskStatusText = "Afsluttet";
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            var newMail = new EmailQueue()
            {
                Created = DateTime.Now, FromEmailAddress = "*****@*****.**", FromName = "IT Forum A/S - Support", ToEmailAddress = contact.Contact_Work_EMail, ToName = contact.Contact_Name, Subject = $"[#{ticketNumber}] Opdateret '{subject}'", BodyText = $"Din sag er blevet opdateret\r\n\r\nAnsvarlig tekniker: {technician}\r\nStatus på sag: {taskStatusText}\r\n\r\nDu kan navigere til supportsiden for at se flere detaljer om den nye status\r\n\r\nLink: {ticketUrl}\r\n\r\n Med venlig hilsen\r\nIT Forum Support"
            };

            return newMail;
        }
        public static EmailQueue CreateTicketOprettetMail(Contact contact, string subject, int ticketNumber, string siteUrl)
        {
            var ticketUrl = $"{siteUrl.TrimEnd('/')}/ticket/edit/{ticketNumber}";

            var newMail = new EmailQueue()
            {
                Created = DateTime.Now,
                FromEmailAddress = "*****@*****.**",
                FromName = "IT Forum A/S - Support",
                ToEmailAddress = contact.Contact_Work_EMail,
                ToName = contact.Contact_Name,
                Subject = $"[#{ticketNumber}] Angående '{subject}'",
                BodyText = $"Tak for din henvendelse\r\n\r\nDin henvendelse har fået nummeret #{ticketNumber}. Det er vigtigt, at denne tekst bibeholdes på fremtidig kommunikation, da den anvendes til at identificere henvendelser angående denne sag.\r\n\r\n\r\n\r\nLink: {ticketUrl}\r\n\r\n Med venlig hilsen\r\nIT Forum Support"
            };

            return newMail;
        }
        private TaskLog LogSupport(IORunEntities dc, Task task, Contact contact, EmailMessage exchangeMail, int ticketNumber)
        {
            var logText = $"{exchangeMail.Subject}:\n\n{exchangeMail.Body.Text}";

            var newTaskLog = TaskRepository.CreateTaskLog(task.Task_GUID, dc, null, contact.Contact_GUID);
            newTaskLog.TaskLog_WebVisible = 1;
            newTaskLog.TaskLog_InternalText = logText.AsEol();
            newTaskLog.TaskLog_ExternalText = logText.AsEol();

            dc.TaskLogs.Add(newTaskLog);

            task.Task_UpdatedByContactGUID = contact.Contact_GUID;
            task.Task_UpdatedByContactDate = DateTime.Now;

            log.Info($"Logget support {logText} på ticket {ticketNumber}");

            return newTaskLog;
        }