Ejemplo n.º 1
0
        public void FetchEmailFolder()
        {
            try
            {
                EmailAutomationModel model = generateModel();

                var list = _presentor.FetchMailboxes(model);

                cmbFolders.DataSource    = list;
                cmbFolders.DisplayMember = "Name";
                cmbFolders.ValueMember   = "FullName";
                cmbFolders.SelectedIndex = list.ToList().FindIndex(x => x.Name.ToUpper() == "INBOX");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Ejemplo n.º 2
0
        public void PlayEmailAutomation(object objModel)
        {
            EmailAutomationModel model = objModel as EmailAutomationModel;

            var         ea = new EmailAutomation();
            IMailClient client;

            ea.ActionChangedEvent += (s, e) =>
            {
                Actionchanged?.Invoke(s, e);
            };

            ea.ProgressValueChangedEvent += (s, e) =>
            {
                ProgressValueChanged?.Invoke(s, e);
            };

            if (model.IsProtocolImap)
            {
                client = new ImapClient(model.Hostname, model.Port, model.IsSecure);
            }
            else
            {
                client = new Pop3Client(model.Hostname, model.Port, model.IsSecure);
            }

            ea.MailCount = model.MailsToDisplay;

            ea.PlayEmailAutomation(client, model.Username, model.Password, model.MailSearchCriteria, model.MailBox);

            ea.ProgressValueChangedEvent -= (s, e) =>
            {
                ProgressValueChanged?.Invoke(s, e);
            };

            ea.ActionChangedEvent -= (s, e) =>
            {
                Actionchanged?.Invoke(s, e);
            };

            ea = null;
        }
Ejemplo n.º 3
0
        private void btnFetchEmails_Click(object sender, EventArgs e)
        {
            lvInbox.Items.Clear();

            try
            {
                EmailAutomationModel model = generateModel();

                model.MailSearchCriteria = generateSearchCriteria();

                model.MailsToDisplay = Convert.ToInt32(tbMailCount.Text.Trim());

                model.MailBox = (rdbImap.Checked) ? cmbFolders.SelectedValue.ToString() : "Inbox";

                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(_presentor.PlayEmailAutomation);
                System.Threading.Thread t = new System.Threading.Thread(start);
                t.Start(model);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public IEnumerable <Mailbox> FetchMailboxes(EmailAutomationModel model)
        {
            var client = new ImapClient(model.Hostname, model.Port, model.IsSecure);

            return(new EmailAutomation().FetchMailboxes(client, model.Username, model.Password));
        }