/// <summary> /// Converts a emailServiceDto to Data.EmailLog in order to save email log to database /// </summary> /// <param name="emailServiceDto">emailServiceDto contains the information related to email which is being saved.</param> /// <param name="sentStatus">sentStatus is the status of email. It is true is its sent otherwise false.</param> /// <returns>Data.EmailLog having information mapped from DatTransferObject.EmailServiceDto</returns> public static EmailLog EmailLog(EmailServiceDto emailServiceDto, bool sentStatus) { return(new EmailLog { Body = emailServiceDto.Body, CreationDate = Functions.GetCurrentDate(), CreationTime = Functions.GetCurrentTime(), MailFrom = emailServiceDto.EmailFrom, MailTo = emailServiceDto.ListToEmailString(), SendStatus = sentStatus, Status = true, Subject = emailServiceDto.Subject }); }
/// <summary> /// Send email to patient in case of successfull registration. /// </summary> /// <param name="patientDto">patientDto is the information model for patient.</param> private void SendMail(PatientDto patientDto) { var emailList = new List <string>(); emailList.Add(patientDto.EmailId); var emailDto = new EmailServiceDto(Strings.PatientRegisteredSubject, Functions.CreateMailBody(patientDto.EmailId, patientDto.FirstName), Strings.UserEmailId, Strings.UserEmailPassword, emailList, Strings.SmtpServer, Integers.PortNumberForEmail, true); var emailer = new EmailSender(emailDto); emailer.Send(); using (var unitOfWork = new UnitOfWork()) { unitOfWork.EmailLogs.Add(DtoToDatabase.EmailLog(emailDto, true)); unitOfWork.Complete(); } }
/// <summary> /// Private method to send a verification email to a new user. /// </summary> /// <param name="loginDto">loginDto contains login detail of a new user trying to log in.</param> /// <param name="emailId">emailId is the email id of the user who is registering himself on the system</param> /// <param name="verificationCode">verificationCode is the code to send to the user. It is always 6 digits.</param> private void SendMail(string handle, string verificationCode, string emailId, bool isForgotPasswordMail) { var emailList = new List <string>(); emailList.Add(emailId); var mailSubject = Strings.SuccessfullRegistrationSubject; var mailBody = Functions.CreateMailBody(handle, emailId, verificationCode); if (isForgotPasswordMail) { mailBody = Functions.CreateMailBodyForgotPassword(handle, verificationCode, emailId); mailSubject = Strings.ForgotPasswordRequest; } var emailDto = new EmailServiceDto(mailSubject, mailBody, Strings.UserEmailId, Strings.UserEmailPassword, emailList, Strings.SmtpServer, Integers.PortNumberForEmail, true); var emailer = new EmailSender(emailDto); emailer.Send(); using (var unitOfWork = new UnitOfWork()) { unitOfWork.EmailLogs.Add(DtoToDatabase.EmailLog(emailDto, true)); unitOfWork.Complete(); } }
/// <summary> /// Constructor for email sender class /// </summary> /// <param name="subject">subject is the subbject related to the email</param> /// <param name="body">body is the body content of the email</param> /// <param name="emailFrom">emailFrom is the email address of the sender</param> /// <param name="emailPassword">emailPassword is the password of the sender</param> /// <param name="emailTo">emailTo is the list of emails to send to</param> /// <param name="smtpServer">smtpServer is the name of the SMTP server to use in order to send emails</param> /// <param name="portNumber">portNumber is the port number for emailing</param> /// <param name="htmlEnabled">htmlEnabled is the boolean flag to flag whether html is enabled or not</param> public EmailSender(EmailServiceDto emailInfo) { EmailInfo = emailInfo; }