Esempio n. 1
0
        private void SendMail(BenQGuru.eMES.Domain.Alert.Alert alert)
        {
            BenQGuru.eMES.Web.Helper.ESmtpMail mail = this.GetNewMail();

            //收件人
            BenQGuru.eMES.BaseSetting.UserFacade userfacade = new BenQGuru.eMES.BaseSetting.UserFacade(DataProvider);

            int recipientCount = 0;

            foreach (ListItem li in this.lstUser.Items)
            {
                if (li.Value != null && li.Value != string.Empty)
                {
                    BenQGuru.eMES.Domain.BaseSetting.User user = userfacade.GetUser(li.Value) as BenQGuru.eMES.Domain.BaseSetting.User;
                    if (user != null && user.UserEmail != null && user.UserEmail != string.Empty && user.UserEmail.IndexOf("@") != -1)
                    {
                        mail.AddRecipient(user.UserName, user.UserEmail);
                        recipientCount++;
                    }
                }
            }

            if (recipientCount > 0)
            {
                mail.Body = alert.AlertMsg;

                if (!mail.Send())
                {
                    BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType(), mail.ErrorMessage);
                }
            }
        }
Esempio n. 2
0
        public static void SendMail(string currentUserMail, object[] users, MailMessage mailMessage)
        {
            BenQGuru.eMES.Web.Helper.ESmtpMail smtp = new BenQGuru.eMES.Web.Helper.ESmtpMail();
            for (int i = 0; i < users.Length; i++)
            {
                string eMail = (users[i] as User).UserEmail;
                if (eMail.Trim().Length == 0)
                {
                    continue;
                }

                smtp.AddRecipient(eMail);
            }
            smtp.MailDomain         = System.Configuration.ConfigurationSettings.AppSettings["MailDomain"].ToString();
            smtp.MailServerUserName = System.Configuration.ConfigurationSettings.AppSettings["MailServerUserName"].ToString();
            smtp.MailServerPassWord = CommonFunction.DESDeCrypt(System.Configuration.ConfigurationSettings.AppSettings["MailServerPassWord"].ToString());
            smtp.Subject            = mailMessage.Subject;
            smtp.Body     = mailMessage.Body;
            smtp.From     = currentUserMail;
            smtp.FromName = "MESϵͳ";
            smtp.Html     = true;
            smtp.Send();
        }