public void EmailSender() { while (_running) { foreach (Appointment appointment in _appointments) { DateTime now = DateTime.Now; double hoursToAppointment = appointment.NotificationTime.TotalHours; if (appointment.DateAndTime > now && appointment.DateAndTime <= now.AddHours(hoursToAppointment) && appointment.EmailNotification) { foreach (User user in appointment.Participants) { if (_clientRepo.IsClient(user)) { _mailNotification.SendReminderEmail(appointment, user as Client); appointment.EmailNotification = false; _persistable.EditAppointment(appointment); } } } } Thread.Sleep(TimeSpan.FromMinutes(1)); } }
public void AppointmentCreatedEmail(Appointment appointment) { MimeMessage message = new MimeMessage(); message.From.Add(new MailboxAddress("Kaare Veggerby Sandbøl", "*****@*****.**")); User user = new User(); foreach (User tempUser in appointment.Participants) { if (_clientRepo.IsClient(tempUser)) { user = tempUser; message.To.Add(new MailboxAddress(user.Name, user.Email)); } } message.Subject = "Bekræftelses Email til " + user.Name; message.Body = new TextPart("plain") { Text = @"Dette er en bekræftigelse på at " + user.Name + "'s aftale d. " + appointment.DateAndTime.ToString("dd/MM/yyyy HH:mm") + "." + "\n Vi glæder os til at se dig" + "\n Venlig hilsen" + "\n Semplito" }; using (SmtpClient client = new SmtpClient()) { client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect("smtp.sendgrid.net", 587, false); client.Authenticate("apikey", "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"); client.Send(message); client.Disconnect(true); } }
public List <UserView> GetClientsFromAppointmentView(AppointmentView appoView) { List <UserView> users = appoView.Users; List <UserView> clients = new List <UserView>(); foreach (UserView user in users) { if (_clientRepo.IsClient(user)) { clients.Add(user); } } return(clients); }