示例#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
 /// <summary>
 /// Непосредственно отправка писем
 /// </summary>
 /// <param name="dtSend"></param>
 /// <param name="emailSender"></param>
 /// <param name="emails"></param>
 public void SendEmails(EmailSendServiceClass emailSender,
                        ObservableCollection <Email> emails)
 {
     this.emailSender = emailSender; // Экземпляр класса, отвечающего за отправку писем
     this.emails      = emails;
     timer.Tick      += Timer_Tick;
     timer.Interval   = new TimeSpan(0, 0, 1);
     timer.Start();
 }