Example #1
0
        public static void SendGroupMailBroadCast(List <string> emails, string composedMessage, string subject)
        {
            try
            {
                _db = new ScherpDbContext();
                var ms = _db.MailSettings;
                foreach (var item in ms)
                {
                    // Command line argument must the the SMTP host.
                    SmtpClient client = new SmtpClient
                    {
                        Port                  = Convert.ToInt16(item.MailPort),
                        Host                  = item.MailHost,
                        EnableSsl             = Convert.ToBoolean(item.EnableSsl),
                        Timeout               = 2000000,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = true,
                        Credentials           = new System.Net.NetworkCredential(item.MailFrom, item.MailPwd)
                    };

                    foreach (string m in emails)
                    {
                        MailMessage mm = new MailMessage(item.MailFrom, m, subject, composedMessage)
                        {
                            IsBodyHtml   = true,
                            BodyEncoding = Encoding.UTF8,
                            DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                        };

                        client.Send(mm);
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 public BaseRepository()
 {
     _dbContext = new ScherpDbContext();
 }