Exemplo n.º 1
0
        public void Notification(string[] to, string body)
        {
            MailConfiguration  mailConfiguration = mailConfigurationLazy.Value;
            List <MailMessage> msgList           =
                GetSendMessageList(mailConfiguration.Account,
                                   mailConfiguration.Name, to, "待办通知", body);

            foreach (var message in msgList)
            {
                smtpClientLazy.Value.Send(message);
            }
        }
Exemplo n.º 2
0
        static MailService()
        {
            MailConfiguration mailConfiguration = mailConfigurationLazy.Value;

            if (mailConfiguration != null)
            {
                SmtpClient _smtp = smtpClientLazy.Value;
                _smtp.Host                  = mailConfiguration.Host;
                _smtp.Port                  = mailConfiguration.Port;
                _smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                _smtp.EnableSsl             = mailConfiguration.EnableSsl == 1;
                _smtp.UseDefaultCredentials = true;
                _smtp.Credentials           =
                    new NetworkCredential(mailConfiguration.Account,
                                          mailConfiguration.Password);
            }
        }
Exemplo n.º 3
0
        public void Notification(string[] to, string body)
        {
            MailConfiguration  mailConfiguration = mailConfigurationLazy.Value;
            List <MailMessage> msgList           =
                GetSendMessageList(mailConfiguration.Account,
                                   mailConfiguration.Name, to, "待办通知", body);

            foreach (var message in msgList)
            {
                try
                {
                    smtpClientLazy.Value.Send(message);
                }
                catch (Exception ex)
                {
                    logging.Error(ex.ToString());
                }
            }
        }