예제 #1
0
        private void SendEmployeeLeaveDeletionNotificationList()
        {
            try
            {
                List <EmailAlert> emailAlertList = EmailAlert.GetEmployeeLeaveDeletionNotificationList(Convert.ToDateTime(TextBoxStartDate.Text), Convert.ToDateTime(TextBoxEndDate.Text), this.employeeId, DropDownListLeaveType.SelectedItem.Text);

                foreach (EmailAlert emailAlert in emailAlertList)
                {
                    MailMessage mailMessage = new MailMessage(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), emailAlert.EmailAddress /*"*****@*****.**"*/);

                    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;
            }
        }