public void EndListening()
        {
            _ewsMailWatcher.EndListening();
            _ewsMailWatcher = null;

            //dispose of trello.
            _settingsService = null;
            _slackService = null;
        }
        private static void MailRecieved(MessageReceived[] messages)
        {
            var slack = new SlackNotificationService();
            foreach (var msg in messages)
            {
                var text =string.Format("Support email received FROM: {0} => TO: {1} -- RE: {2}", msg.From, string.Join(",", msg.To), msg.Subject);
                Console.WriteLine(text);

                slack.Notify(_supportChannelId, text + " -- please allow a litle while for Trello to find and process the email.");
            }
        }
        public Service1()
        {
            InitializeComponent();

            var settingsService = new SettingsService();
            var settings = settingsService.GetSettinngs();

            var ewsMailWatcher = new EwsMailWatcher(settings.EwsSettings, settings.TrelloSettings.BoardForwardingEmailAddress);
            var slackService = new SlackNotificationService();

            _supportManager = new SupportManager(ewsMailWatcher, slackService, settingsService);
        }
 public SupportManager(EwsMailWatcher ewsMailWatcher, SlackNotificationService slackService, SettingsService settingsService)
 {
     _ewsMailWatcher = ewsMailWatcher;
     _slackService = slackService;
     _settingsService = settingsService;
 }