Beispiel #1
0
 public ImapIdler(string address, string password, EventLog eventLog)
 {
     _log = new SafeLog();
     _cfg = new Conf(_log);
     _cfg.Init();
     _eventLog = eventLog;
     _timeout  = new TimeSpan(0, _cfg.AutoResponderIdleTimeoutMinutes, _cfg.AutoResponderIdleTimeoutSeconds);            // 30 sec timeout for idle
     _oDb      = new SqlConnection();
     InitImap(address, password);
 }
Beispiel #2
0
        public void TestMailbee()
        {
            _cfg = new Conf(_log);
            _cfg.Init();

            try
            {
                Global.LicenseKey = _cfg.MailBeeLicenseKey;
            }
            catch (MailBeeLicenseException e)
            {
                _log.Error("License key is invalid: {0}", e);
                //Mailer.Mailer.SendMail(_cfg.TestAddress, _cfg.TestPassword, "EzAutoresonder Error", e.ToString(), "*****@*****.**");
            }             // try

            _imap = new Imap {
                SslMode = MailBee.Security.SslStartupMode.OnConnect
            };

            // Connect to IMAP server
            _imap.Connect(_cfg.Server, _cfg.Port);
            _log.Info("Connected to the server");

            // Log into IMAP account
            _imap.Login("", "");           //todo enter a login
            _log.Info("Logged into the server");

            // Select Inbox folder
            _imap.ExamineFolder("Inbox");
            var uids = (UidCollection)_imap.Search(true, "UNSEEN", null);

            if (uids.Count > 0)
            {
                // Download all the messages found by Search method
                MailMessageCollection msgs = _imap.DownloadMessageHeaders(uids.ToString(), true);

                // Iterate througn the messages collection and display info about them
                foreach (MailMessage msg in msgs)
                {
                    Console.WriteLine("Message #" + msg.IndexOnServer.ToString(CultureInfo.InvariantCulture) +
                                      " has subject: " + msg.Subject + "  from: " + msg.From.Email + " received on: " +
                                      msg.DateReceived);
                }
            }
        }
Beispiel #3
0
        public AutoResponderService()
        {
            InitializeComponent();
            _log = new SafeLog();
            _cfg = new Conf(_log);
            _cfg.Init();

            if (!EventLog.SourceExists("AutoResponderServiceSource"))
            {
                EventLog.CreateEventSource("AutoResponderServiceSource", "AutoResponderServiceLog");
            }

            _eventLog.Source = "AutoResponderServiceSource";
            _eventLog.Log    = "AutoResponderServiceLog";
            string[] mails     = _cfg.AutoResponderMails.Split(' ');
            string[] passwords = _cfg.AutoResponderPasswords.Split(' ');
            if (mails.Length != passwords.Length)
            {
                _eventLog.WriteEntry("Wrong emails passwords count", EventLogEntryType.Error);
                return;
            }

            for (int i = 0; i < mails.Length; i++)
            {
                ImapIdler ImapIdler;
                try
                {
                    ImapIdler = new ImapIdler(mails[i], passwords[i], _eventLog);
                }
                catch (Exception)
                {
                    continue;
                }
                _imapIdlerList.Add(ImapIdler);
            }
        }
Beispiel #4
0
 public void TestConfBase()
 {
     _cfg = new Conf(_log);
     _cfg.Init();
 }
Beispiel #5
0
 public void Init()
 {
     _cfg = new Conf(_log);
     _cfg.Init();
 }