private void SendEmail(SendNotificationEnd notification) { using (var client = new SmtpClient()) { this.logger.Debug("Sending a sick leave email notification for user {0}", notification.Employee.Metadata.Name); var msg = this.CreateMimeMessage(this.GetNotificationText(notification)); client.Connect( this.smtpConfig.Host, this.smtpConfig.Port, this.smtpConfig.UseTls ? SecureSocketOptions.StartTls : SecureSocketOptions.None); client.Authenticate(this.smtpConfig.User, this.smtpConfig.Password); client.Send(msg); client.Disconnect(true); this.logger.Debug("Sick leave email notification for user {0} was succesfully sent", notification.Employee.Metadata.Name); } }
private string GetNotificationText(SendNotificationEnd notification) { return(string.Format(this.mailConfig.Body, notification.Employee.Metadata.Name, notification.DatesPeriod.StartDate.ToString("D"))); }