Example #1
0
        private void BtnSendPlan_OnClick(object sender, RoutedEventArgs e)
        {
            SchedulerClass sc = new SchedulerClass();

            DateTime dtSendDateTime = (ldSchedulDateTimes.SelectedDate ?? DateTime.Today);

            if (tpSchedulTimes.Value.HasValue)
            {
                int hours   = tpSchedulTimes.Value.Value.Hour;
                int minutes = tpSchedulTimes.Value.Value.Minute;
                dtSendDateTime = dtSendDateTime.AddHours(hours).AddMinutes(minutes);
            }
            if (dtSendDateTime < DateTime.Now)
            {
                SendEndWindow sew =
                    new SendEndWindow("Дата и время отправки писем не могут быть раньше, чем настоящее время");
                sew.ShowDialog();
                return;
            }

            EmailSendServiceClass emailSender = CreateEmailSendService();

            if (emailSender != null)
            {
                sc.SendEmails(dtSendDateTime, emailSender, (IQueryable <Email>)dgEmails.ItemsSource, this);
            }
        }
Example #2
0
        public void SendMessageLater(IQueryable <Emails> emails, Smtp selectedSmtp, DateTime selectedSendDate, string selectedSendTime)
        {
            if (IsFillError())
            {
                return;
            }
            AuthorizationWindow authWindow = new AuthorizationWindow();

            _scheduler = new SchedulerClass();
            TimeSpan tsSendTime = _scheduler.GetSendTime(selectedSendTime);

            if (tsSendTime == new TimeSpan())
            {
                MessageBox.Show("Некорректный формат даты", "ВНИМАНИЕ!");
                return;
            }
            DateTime dtSendDateTime = selectedSendDate.Add(tsSendTime);

            if (dtSendDateTime < DateTime.Now)
            {
                MessageBox.Show("Дата и время отправи не могут быть раньше настоящего времени", "ВНИМАНИЕ!");
                return;
            }
            if (authWindow.ShowDialog() == true)
            {
                _sendService = new EmailSendServiceClass(selectedSmtp, authWindow.authSettings, mailSettings);
                _sendService.SendMails(emails);
            }
        }
Example #3
0
 /// <summary>
 /// Отправка писем
 /// </summary>
 /// <param name="dtSend"></param>
 /// <param name="emailSender"></param>
 /// <param name="emails"></param>
 public void SendEmails(DateTime dtSend, EmailSendServiceClass emailSender, IQueryable <Emails> emails)
 {
     _emailSenderService = emailSender;
     _dtSend             = dtSend;
     _emails             = emails;
     _timer.Tick        += Timer_Tick;
     _timer.Interval     = new TimeSpan(0, 0, 1);
     _timer.Start();
 }
        private void ButtonSend_Click(object sender, RoutedEventArgs e)
        {
            WpfTestMailSender.Server = TextBoxServer.Text;
            WpfTestMailSender.Port   = Int32.Parse(TextBoxPort.Text);
            string from         = TextBoxFrom.Text;
            string to           = TextBoxTo.Text;
            string subject      = TextBoxSubject.Text;
            string body         = TextBoxBody.Text;
            var    emailService = new EmailSendServiceClass(TextBoxLogin.Text, PasswordBoxPassword.SecurePassword);

            emailService.SendMail(from, to, subject, body);
        }
Example #5
0
        private void BtnSendNow_OnClick(object sender, RoutedEventArgs e)
        {
            EmailSendServiceClass       emailSender = CreateEmailSendService();
            Dictionary <string, string> emails      =
                ((IQueryable <Email>)dgEmails.ItemsSource).ToDictionary(k => k.Email1, p => p.Name);

            if (emailSender != null)
            {
                emailSender.ShowResultOfSend += SendEndWindowCreate;
                new Thread(() => { emailSender.SendMail(emails); }).Start();
            }
        }
Example #6
0
        public void SendMessage(IQueryable <Emails> emails, Smtp selectedSmtp)
        {
            if (IsFillError())
            {
                return;
            }
            AuthorizationWindow authWindow = new AuthorizationWindow();

            if (authWindow.ShowDialog() == true)
            {
                _sendService = new EmailSendServiceClass(selectedSmtp, authWindow.authSettings, mailSettings);
                _sendService.SendMails(emails);
            }
        }
Example #7
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            //var from = new MailAddress("@gmail.com", "Test!!!");
            //var to = new MailAddress("@yandex.ru");

            var from = new MailAddress("*****@*****.**", "Test!!!");
            var to   = new MailAddress("*****@*****.**");

            var message = new MailMessage(from, to);

            message.Subject = tbSubjectMail.Text;
            message.Body    = tbBodyMail.Text;

            EmailSendServiceClass sendMail = new EmailSendServiceClass();

            sendMail.SendMeil(ConfigMailServerClass.Host, ConfigMailServerClass.Port, tbLogin.Text, pasBox.SecurePassword, message);
        }