public static string NewBooking(int id) { var token = new Token { BookingId = id, Expiration = DateTime.UtcNow.AddDays(1), Key = RandomHelper.RandomString(14) }; TokenHelper.Add(token); var booking = BookingHelper.Get(id); if (booking == null) { return("No valid booking registered"); } var emailRecipientsList = EmailHelper.GetNewBookingEmails(); var mailMessage = new MailMessage(); mailMessage.From = new MailAddress(EmailHelper.GetSmtpUsername(), "Rensvik Samfunnshus"); foreach (var emailRecipient in emailRecipientsList) { mailMessage.To.Add(emailRecipient); } mailMessage.Subject = $"Ny booking ({DateTime.UtcNow:dd.MM HH:mm})"; mailMessage.BodyEncoding = System.Text.Encoding.UTF8; var body = $"Navn: {booking.Name} \r\n"; body += $"Telefon: {booking.Telephone} \r\n"; body += $"Område: {booking.Area} \r\n"; if (booking.From == booking.To) { body += $"Dato: {booking.From:dd.MM} \r\n"; } else { body += $"Dato: {booking.From:dd.MM} - {booking.To:dd.MM} \r\n"; } body += $"Tid: {booking.TimeOfDay} \r\n"; body += $"Formål: {booking.Purpose} \r\n"; body += $"Kommentar: {booking.Comment} \r\n"; body += $"Marker denne bookingen som reservert ved å klikke lenken nedenfor\r\n"; body += Settings.NewBookingEmailLinkTarget + $"?t={token.Key}&id={id}"; mailMessage.Body = body; using (var client = new SmtpClient()) { client.Send(mailMessage); } return("New booking actions complete"); }