Ejemplo n.º 1
0
        public void threadOfMainSending(MessageMembers mb)
        {
            var thread = new Thread(new ParameterizedThreadStart(sendMail));

            j.Show();
            thread.Start(mb);
        }
Ejemplo n.º 2
0
        public void testMail(object objMember)
        {
            MessageMembers mb = objMember as MessageMembers;
            TestSending    ts = new TestSending();

            ts.sendMail(mb);
        }
Ejemplo n.º 3
0
        public override void sendMail(object objMember)
        {
            MessageMembers md = objMember as MessageMembers;

            try
            {
                if (md.Subject.Length == 0)
                {
                    throw new EmptySubject();
                }
                if (md.Body.Length == 0)
                {
                    throw new EmptyBody();
                }
                md.actBtnTest.Enabled = false;
                MailAddress from = new MailAddress(Data._EmailLogin, Data._CompanyName);
                SmtpClient  smtp = new SmtpClient(Data._SmtpAddress, Data._SmtpPort);
                if (Data._EnableSSL)
                {
                    smtp.EnableSsl = true;
                }
                smtp.Credentials = new NetworkCredential(Data._EmailLogin, Data._Password);
                MailAddress to      = new MailAddress(Data._TestAddress);
                MailMessage message = new MailMessage(from, to);
                message.Subject = md.Subject;
                message.Body    = md.Body;
                if (Data._EnableHTML)
                {
                    message.IsBodyHtml = true;
                }
                smtp.Send(message);
                MessageBox.Show("Отправлено успешно на " + Data._TestAddress, "Тестовая отправка", MessageBoxButtons.OK);
                md.actBtnTest.Enabled = true;
            }
            catch (Exception exc)
            {
                if (exc is EmptySubject)
                {
                    (exc as EmptySubject).ShowMessage();
                }
                else if (exc is EmptyBody)
                {
                    (exc as EmptyBody).ShowMessage();
                }
                else
                {
                    (exc as OwnExceptions).ShowMessage();
                }
            }
        }
Ejemplo n.º 4
0
        private void _view_mainSendingClick(object sender, EventArgs e)
        {
            MessageMembers mb = new MessageMembers(_view.Subject, _view.Body, null, null);

            _model.threadOfMainSending(mb);
        }
Ejemplo n.º 5
0
        private void _view_testingSendingStrip(object sender, EventArgs e)
        {
            MessageMembers mb = new MessageMembers(_view.Subject, _view.Body, null, _view.actBtnTest);

            _model.threadOfTestSending(mb);
        }
Ejemplo n.º 6
0
        public virtual void sendMail(object objMember)
        {
            MessageMembers mb = objMember as MessageMembers;

            try
            {
                if (mb.Subject.Length == 0)
                {
                    throw new EmptySubject();
                }
                if (mb.Body.Length == 0)
                {
                    throw new EmptyBody();
                }

                MailAddress from = new MailAddress(Data._EmailLogin, Data._CompanyName);
                SmtpClient  smtp = new SmtpClient(Data._SmtpAddress, Data._SmtpPort);
                if (Data._EnableSSL)
                {
                    smtp.EnableSsl = true;
                }
                smtp.Credentials = new NetworkCredential(Data._EmailLogin, Data._Password);

                ThreadPool.QueueUserWorkItem(delegate
                {
                    for (int i = 0; i < Data._Destination.Count; i++)
                    {
                        if (isNotFirstLetter)
                        {
                            Thread.Sleep(Data._IntervalBetween * 1000); //соблюдать интервал между письмами, начиная со второго
                        }
                        MailAddress to      = new MailAddress(Data._Destination[i]);
                        MailMessage message = new MailMessage(from, to);
                        message.Subject     = mb.Subject;
                        message.Body        = mb.Body;
                        if (Data._EnableHTML)
                        {
                            message.IsBodyHtml = true;
                        }
                        smtp.Send(message);
                        isNotFirstLetter = true;                        //для thread.Sleep() выше (уже не первое письмо) */

                        j.Invoke((MethodInvoker)(() => j.addToList())); //не виснет, йоу
                    }
                });
            }
            catch (Exception exc)
            {
                if (exc is EmptyBody)
                {
                    (exc as EmptyBody).ShowMessage();
                }
                else if (exc is EmptySubject)
                {
                    (exc as EmptySubject).ShowMessage();
                }
                else
                {
                    throw new OwnExceptions();
                }
            }
        }
Ejemplo n.º 7
0
        public void threadOfTestSending(MessageMembers mb)
        {
            var thread = new Thread(new ParameterizedThreadStart(testMail));

            thread.Start(mb);
        }
Ejemplo n.º 8
0
 private void _view_testingSendingStrip(object sender, EventArgs e)
 {
     MessageMembers mb = new MessageMembers(_view.Subject, _view.Body, null, _view.actBtnTest);
     _model.threadOfTestSending(mb);
 }
Ejemplo n.º 9
0
 private void _view_mainSendingClick(object sender, EventArgs e)
 {
     MessageMembers mb = new MessageMembers(_view.Subject, _view.Body, null, null);
     _model.threadOfMainSending(mb);
 }
Ejemplo n.º 10
0
 public void threadOfTestSending(MessageMembers mb)
 {
     var thread = new Thread(new ParameterizedThreadStart(testMail));
     thread.Start(mb);
 }
Ejemplo n.º 11
0
 public void threadOfMainSending(MessageMembers mb)
 {
     var thread = new Thread(new ParameterizedThreadStart(sendMail));
     j.Show();
     thread.Start(mb);
 }