private static MailMessage GetUnconfirmedAppointmentMailMessage(ActionResult <IEnumerable <CustomerAppointmentInformation> > appointments) { string newHtml = ""; MailMessage mailmessage = new MailMessage { IsBodyHtml = true, From = new MailAddress("*****@*****.**") }; mailmessage.To.Add(new MailAddress("*****@*****.**")); mailmessage.Subject = "Rendez-vous non-confirmés pour le " + DateConverter.CurrentEasternDateTime().AddDays(1).ToString("dd/MM/yyyy"); string htmlWithNewAppointments = GetHtmlWithUnconfirmedAppointments(appointments); using (StreamReader reader = File.OpenText("EmailTemplate/unconfirmedAppointments.html")) { var htmlFile = reader.ReadToEnd(); newHtml = htmlFile.Replace("[NewAppointmentsy]", htmlWithNewAppointments); mailmessage.Body = newHtml; return(mailmessage); } }
private static MailMessage GetMailMessageToConfirmAppointment(string emailTo, DateTime AppointmentDateTime) { using (StreamReader reader = File.OpenText("EmailTemplate/index.html")) { string newHtml = ""; MailMessage mailmessage = new MailMessage { IsBodyHtml = true, From = new MailAddress("*****@*****.**") }; mailmessage.To.Add(new MailAddress(emailTo)); mailmessage.Subject = "Confirmation de rendez-vous"; var htmlFile = reader.ReadToEnd(); newHtml = htmlFile.Replace("[DateOfTheDayx]", DateConverter.CurrentEasternDateTime().Date.ToString("yyyy/MM/dd")); newHtml = newHtml.Replace("[TimeOfTheDayx]", DateConverter.CurrentEasternDateTime().ToShortTimeString().ToString()); newHtml = newHtml.Replace("[AppointmentHourx]", AppointmentDateTime.ToShortTimeString()); newHtml = newHtml.Replace("[AppointmentDatex]", AppointmentDateTime.Date.ToString("yyyy/MM/dd")); mailmessage.Body = newHtml; return(mailmessage); } }