예제 #1
0
 /// <summary>
 /// Таймер
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (dtSend.ToShortTimeString() == DateTime.Now.ToShortTimeString())
     {
         emailSender.SendMails(_mailSubject, _mailBody, _listEmails);
         timer.Stop();
     }
 }
예제 #2
0
 private void TimerTick(object sender, EventArgs e)
 {
     if (_dicDates.Count > 0)
     {
         DateTime _nextSend = _dicDates.Keys.First <DateTime>();
         if (_nextSend.ToShortDateString() == DateTime.Now.ToShortDateString() && _nextSend.ToShortTimeString() == DateTime.Now.ToShortTimeString())
         {
             _mailSubject = $"Рассылка от {_nextSend} ";
             _mailBody    = _dicDates[_dicDates.Keys.First <DateTime>()];
             _emailSender.SendMails(_listEmails);
             MessageAfterOneSend?.Invoke($"Письмо от {_nextSend} отправлено");
             _dicDates.Remove(_dicDates.Keys.First <DateTime>());
         }
     }
     else if (_dicDates.Count == 0)
     {
         _timer.Stop();
         MessageAfterSendAll?.Invoke("Запланированная отправка писем завершена");
     }
 }