private void SendEmployeeLeaveReportsToDecisionNotification(int employeeLeaveDaysId) { try { MailMessage mailMessage = new MailMessage(); string emailAddress = ""; string subject = ""; string body = ""; List <EmailAlert> emailAlertList = EmailAlert.GetEmployeeLeaveReportsToDecisionNotification(employeeLeaveDaysId); foreach (EmailAlert emailAlert in emailAlertList) { emailAddress = emailAlert.EmailAddress; mailMessage.CC.Add(emailAlert.EmailAddressReportsTo); subject = emailAlert.EmailSubject; body = emailAlert.EmailBody;; } MailMessage fromToMailMessage = new MailMessage(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), emailAddress /*"*****@*****.**"*/); mailMessage.From = fromToMailMessage.From; mailMessage.To.Add(emailAddress); mailMessage.Subject = subject; mailMessage.Body = body; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mailRelay"].ToString()); smtpClient.Port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]); smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), ConfigurationManager.AppSettings["password"].ToString()); smtpClient.EnableSsl = true; smtpClient.Send(mailMessage); } catch (Exception ex) { //LabelError.Text = ""; //LabelError.Text += ex.Message; //PanelError.Visible = true; } //try //{ // List<EmailAlert> emailAlertList = EmailAlert.GetEmployeeLeaveReportsToDecisionNotification(employeeLeaveDaysId); // foreach (EmailAlert emailAlert in emailAlertList) // { // MailMessage mailMessage = new MailMessage(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), emailAlert.EmailAddress /*"*****@*****.**"*/); // mailMessage.CC.Add(emailAlert.EmailAddressReportsTo); // mailMessage.Subject = emailAlert.EmailSubject; // mailMessage.Body = emailAlert.EmailBody; // mailMessage.IsBodyHtml = true; // SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mailRelay"].ToString()); // smtpClient.Port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]); // smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), ConfigurationManager.AppSettings["password"].ToString()); // smtpClient.EnableSsl = true; // smtpClient.Send(mailMessage); // } //} //catch (Exception ex) //{ // //LabelError.Text = ""; // //LabelError.Text += ex.Message; // //PanelError.Visible = true; //} }