Пример #1
0
        private void SendMassMail(string message)
        {
            _mail = new MailService();

            int totalSent = 0;

            var uas = new UserAccounts();
            uas.GetAll();

            foreach (UserAccount ua1 in uas.OrderBy(x => x.CreateDate))
            {
                var uad = new UserAccountDetail();
                uad.GetUserAccountDeailForUser(ua1.UserAccountID);

                if (!uad.EmailMessages) continue;

                // safety
               if (ua1.UserName != "bootlegbaron") continue;

                var userAddress = new UserAddress();
                userAddress.GetUserAddress(ua1.UserAccountID);

                System.Threading.Thread.Sleep(200);

                if (_mail.SendMail("*****@*****.**", ua1.EMail, "Das Klub Kalendar 2017 - Competition!", message))
                {
                    totalSent++;
                }
                else
                {
                    uad.EmailMessages = false;
                    uad.Update();
                }
            }

            HttpContext.Current.Response.Write(totalSent);
        }