When creating an appointment i want to send an email out to the patient with details like Time, Date etc. I know the email service i have created works (i have tested it by hardcoding strings into the method with the problem.
The Problem is that i am getting Object reference issues with converting the Time and Date to a string. It does create the appointment data in the database correctly (time and date).
User_Doctor thisDoc = user_DoctorComboBox.SelectedItem as User_Doctor;
User_Patient thisPatient = appointment_Patient_autoComplete.SelectedItem as User_Patient;
Appointment App = AppointmentSlots.SelectedItem as Appointment;
DateTime date = (DateTime)datePickerAppointment.SelectedDate;
TimeSpan timeslot = App.Time;
//For Emailing Patients
string fullname = thisPatient.PatientName + " " + thisPatient.PatientSurname;
string mestime = timeslot.ToString("HH:mm");
string mesdate = date.ToString("MM/dd/yyyy");
string email = thisPatient.aspnet_Users.aspnet_Membership.LoweredEmail;
EmailServiceClient em = new EmailServiceClient();
em.createMessageAsync(email, "Upcomming Appointment", fullname, mestime, mesdate, thisDoc.aspnet_Users.UserName, true);
The problem occures with the strings mestime and mesdate, as well as with getting the email of the user from the database (again this exists in the db, as a nvar)