Trying to develop an app where when a User applies for an appointment, they get email confirmation that the appointment has been received with their details in the email. I've got a linq query( after the appointment is created) to get their details from the database. I've debugged the app, and the details are going through to the mailer method. However, I get a blank email. Is it something to do with the ViewBag.Data?
Here's where I send the details:
var app = (from a in db.Appointments
where appointments.AppointmentId == a.AppointmentId
select a).FirstOrDefault()
UserMailer.AppointmentDetails(app).Send();
My mailer method:
public virtual MvcMailMessage AppointmentDetails(Appointments appointment)
{
ViewBag.Data = appointment;
return Populate(x =>
{
x.Subject = "Appointment Detail";
x.ViewName = "AppointmentDetails";
x.To.Add(appointment.ApplicantEmail);
});
}
Finally the view for the email:
Appointment Details @ViewBag.Data:<br />
Welcome to the App and enjoy your time!<br />
Fixed it, I needed to set up these in the mailer:
ViewBag.Details = appointment.DetailsOfAppointment;
ViewBag.Date = appointment.DateOfAppointment;
ViewBag.Room = appointment.RoomType;
Then assign them in my view