Пример #1
0
        public AccountForm(EmailAccount a)
        {
            InitializeComponent();

            textBoxUsername.Text = a.Username;
            textBoxPassword.Text = a.Password;
            textBoxNickname.Text = a.Nickname;
            textBoxServer.Text = a.Server;
            numericUpDownPort.Value = a.Port;
            checkBoxSsl.Checked = a.EnableSsl;
        }
Пример #2
0
        public EmailAccount GetAccount()
        {
            EmailAccount a = new EmailAccount();
            a.Username = textBoxUsername.Text;
            a.Password = textBoxPassword.Text;
            a.Nickname = textBoxNickname.Text;

            a.Server = textBoxServer.Text;
            a.Port = (int)numericUpDownPort.Value;
            a.EnableSsl = checkBoxSsl.Checked;
            return a;
        }
Пример #3
0
        public void LoadAccounts()
        {
            if (File.Exists(m_accountsFile))
            {
                string[] lines = File.ReadAllLines(m_accountsFile);

                foreach (string line in lines)
                {
                    if (!string.IsNullOrEmpty(line))
                    {
                        EmailAccount account = new EmailAccount(line.Split(','));
                        m_accounts.Add(account);
                    }
                }
            }   
        }
Пример #4
0
 public WrappedItem(EmailAccount account)
 {
     m_account = account;
 }
Пример #5
0
 public MailJob(EmailAccount account, object[] addresses)
 {
     m_account = account;
     m_addresses = addresses;
 }
Пример #6
0
 public void Remove(EmailAccount account)
 {
     m_accounts.Remove(account);
 }
Пример #7
0
 public void Add(EmailAccount account)
 {
     m_accounts.Add(account);
 }
Пример #8
0
 public MailJob(EmailAccount account, object[] addresses)
 {
     m_account   = account;
     m_addresses = addresses;
 }
Пример #9
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (m_timer.Enabled)//表示timer正在工作
            {
                m_timer.Stop();
                m_timer.Enabled = false;
                OnDone();
                return;
            }
            else if (backgroundWorkerMailSender.IsBusy)
            {
                backgroundWorkerMailSender.CancelAsync();
                OnDone();
                return;
            }

            if (comboBoxAccounts.Items.Count < 1)
            {
                QMessageBox.ShowWarning("account can not be empty!");
                return;
            }
            else if (comboBoxAccounts.SelectedIndex < 0)
            {
                QMessageBox.ShowWarning("you must select an account!");
                return;
            }
            else if (String.IsNullOrEmpty(textBoxSubject.Text))
            {
                QMessageBox.ShowWarning("email subject can not be empty!");
                return;
            }
            else if (String.IsNullOrEmpty(richTextBoxBody.Text))
            {
                QMessageBox.ShowWarning("email body can not be empty!");
                return;
            }
            else if (listBoxAddresses.Items.Count <= 0)
            {
                QMessageBox.ShowWarning("recipients can not be empty!");
                return;
            }
            else
            {
                if (checkBoxTimedSend.Checked)
                {
                    if (dateTimePickerTimedSend.Value <= DateTime.Now)
                    {
                        QMessageBox.ShowError("the time is in the past!");
                        return;
                    }
                    m_timer.Interval = dateTimePickerTimedSend.Value.Subtract(DateTime.Now).TotalSeconds * 1000;
                }
                else
                {
                    m_timer.Interval = 1;
                }
            }

            WrappedItem  item = (WrappedItem)comboBoxAccounts.SelectedItem;
            EmailAccount a    = item.Account;

            a.Init(textBoxSubject.Text, richTextBoxBody.Text);
            object[] addresses = new object[listBoxAddresses.Items.Count];
            listBoxAddresses.Items.CopyTo(addresses, 0);
            job = new MailJob(a, addresses);
            m_timer.Start();
            buttonSend.Text    = "Cancel";
            buttonQuit.Enabled = false;

            this.Text = String.Format("{0} - waiting to send...", m_formText);
        }
Пример #10
0
 public WrappedItem(EmailAccount account)
 {
     m_account = account;
 }
Пример #11
0
 private ListViewItem BuildListViewItem(EmailAccount a)
 {
     ListViewItem item = new ListViewItem();
     item.Tag = a;
     ShowAccount(item);
     return item;
 }