Esempio n. 1
0
 public SlackController(ITokenProvider tokenProvider, IMailBot mailbot, IWebClient webclient)
 {
     _tokenProvider = tokenProvider;
     _mailBot       = mailbot;
     _webClient     = webclient;
 }
        public void SendMail(Action sendAction)
        {
            if(Directory.Exists(MailDirectory))
            {
                Directory.Delete(MailDirectory, true);
            }
            Directory.CreateDirectory(MailDirectory);

            var smtpClient = new SmtpClient();

            _mailBot = new MailBot();

            var smtpClientFieldInfo = typeof(MailBot).GetField("_smtpClient", BindingFlags.NonPublic | BindingFlags.Instance);
            smtpClientFieldInfo.SetValue(_mailBot, smtpClient);

            sendAction();

            var fieldInfo = typeof(MailBot).GetField("_queuedMails", BindingFlags.NonPublic | BindingFlags.Instance);
            while((int)fieldInfo.GetValue(_mailBot) != 0)
            {
                Thread.Sleep(10);
            }
        }