public void EmailBooking(AppointmentModel app) { try { Email_Api emailApi = new Email_Api(); Appointment_Api aptms = new Appointment_Api(); var apppointment = aptms.GetAllAppointments().Where(a => a.appointment_ID == app.appointment_ID).First(); var patients = emailApi.GetPatientsAppointments(); Admin_Api adminApi = new Admin_Api(); var patDetails = (adminApi.GetAllPatients()).Where(p => p.pid == apppointment.paitent_ID).First(); MailMessage mailMessage = new MailMessage("*****@*****.**", patDetails.emailID); // Specify the email body mailMessage.Body = "Dear Patient you have booked appointment with Doctor " + app.doctorName + " Appointment ID is " + app.appointment_ID + " appointment time is " + app.timings; mailMessage.Subject = "Success Booking"; SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587); smtpClient.Credentials = new System.Net.NetworkCredential() { UserName = "******", Password = "******" }; smtpClient.EnableSsl = true; smtpClient.Send(mailMessage); } catch (Exception ex) { Utils.Logging(ex, 2); } }
public void EmailToPatients() { try { Email_Api emailApi = new Email_Api(); var patients = emailApi.GetPatientsAppointments(); foreach (var p in patients) { SendEmails(p.emailID, "Dear Patient you have appointment with Doctor"); } } catch (Exception ex) { Utils.Logging(ex, 2); } }