示例#1
0
        private void BtnSendAtOnce_Click(object sender, RoutedEventArgs e)
        {
            string strBody     = BodyPost.Text;
            string strSubject  = SubjectPost.Text;
            string strLogin    = cbSenderSelect.Text;
            string strPassword = cbSenderSelect.SelectedValue.ToString();
            string smtpServ    = cbSmtpSelect.Text;
            int    sPort       = int.Parse(((KeyValuePair <string, int>)cbSmtpSelect.SelectedItem).Value.ToString());

            if (string.IsNullOrEmpty(strLogin))
            {
                MessageBox.Show("Выберите отправителя");
                return;
            }
            if (string.IsNullOrEmpty(strPassword))
            {
                MessageBox.Show("Укажите пароль отправителя");
                return;
            }
            if (string.IsNullOrEmpty(strBody))
            {
                MessageBox.Show("Письмо не заполнено");
                return;
            }
            Classes.EmailSendServiceClass emailSender = new Classes.EmailSendServiceClass(strLogin, strPassword,
                                                                                          strBody, strSubject, smtpServ, sPort);
            var locator = (ViewModelLocator)FindResource("Locator");

            emailSender.SendMails(locator.Main.Emails);
        }
示例#2
0
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (dicDates.Count == 0)
     {
         timer.Stop();
         MessageBox.Show("Письма отправлены");
     }
     else if (dicDates.Keys.First <DateTime>().ToShortTimeString() == DateTime.Now.ToShortTimeString())
     {
         emailSender.strBody    = dicDates[dicDates.Keys.First <DateTime>()];
         emailSender.strSubject = $"Рассылка от {dicDates.Keys.First<DateTime>().ToShortTimeString()}";
         emailSender.SendMails(emails);
         dicDates.Remove(dicDates.Keys.First <DateTime>());
     }
 }