Beispiel #1
0
        private void refreshMessages(ListBox lbEmails)
        {
            EmailClient Client = EmailFactory.GetEmailClient();

            folderMode = false;
            lbEmails.Items.Clear();
            string folderName = Client.getCurrentFolder();

            lbEmails.Items.Add("Folder: " + folderName + " | Select to change folder");

            foreach (EmailMessage message in Messages)
            {
                /*String line = "Subject: " + message.subject + " | From: " + message.sourceAddress +
                 *  " | Date:" + message.date.ToShortDateString() + //" " + message.date.ToShortTimeString() +
                 *  " | Body: " + message.body;*/

                string address;
                if (folderName == "[Gmail]/Sent Mail")
                {
                    address = message.destinationAddress;
                }
                else
                {
                    address = message.sourceAddress;
                }

                String line = message.subject + " | " + address +
                              " | " + message.date.ToShortDateString() + //" " + message.date.ToShortTimeString() +
                              " | " + message.body;


                lbEmails.Items.Add(line);
            }
        }
Beispiel #2
0
        private void FrmDeleteEmail_DeleteEmail_Click(bool isConfirmation)
        {
            //Show();
            frmDeleteEmail.Visible = false;



            int temp = lbEmails.SelectedIndex;

            if (isConfirmation)
            {
                EmailClient Client = EmailFactory.GetEmailClient();
                Client.DeleteMessage(Messages[lbEmails.SelectedIndex]);
                lbEmails.Items.RemoveAt(lbEmails.SelectedIndex);
            }
            if (lbEmails.Items.Count == 0)
            {
                return;
            }
            if (temp < lbEmails.Items.Count)
            {
                lbEmails.SelectedIndex = temp;
            }
            else
            {
                lbEmails.SelectedIndex = temp - 1;
            }
        }
Beispiel #3
0
        private void BtnSelect_Click(object sender, EventArgs e)
        {
            if (lbEmails.SelectedIndex == -1)
            {
                lbEmails.SelectedIndex = 0;
            }

            if (!folderMode)
            {
                if (lbEmails.Items.Count > 0)
                {
                    if (lbEmails.SelectedIndex == 0)
                    {
                        //switch Folder
                        this.lbListFolders();
                    }
                    else if (lbEmails.SelectedIndex > 0)
                    {
                        frmViewEmail.SetMailMessage(Messages[lbEmails.SelectedIndex - 1]);
                        frmViewEmail.Show();
                    }
                }
            }
            else
            {
                EmailClient Client = EmailFactory.GetEmailClient();
                Client.retrieveMail(lbEmails.SelectedItem.ToString());
                Messages = Client.getMailHistory();
                refreshMessages(lbEmails);
            }
        }
Beispiel #4
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            EmailMessage message = new EmailMessage(txtSubject.Text, txtBody.Text, txtTo.Text, txtSubject.Text, new DateTime());
            EmailClient  Client  = EmailFactory.GetEmailClient();

            switch (type)
            {
            case EmailType.Compose:
                Client.sendMessage(message);
                break;

            case EmailType.Forward:
                Client.sendForward(previousMessage, txtSubject.Text, txtBody.Text);
                break;

            case EmailType.Reply:
            case EmailType.ReplyAll:
                Client.sendReply(previousMessage, txtBody.Text);
                break;
            }

            Hide();
            if (Send_Click != null)
            {
                Send_Click(this, e);
            }
        }
Beispiel #5
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            EmailClient client = EmailFactory.GetEmailClient();

            client.setLogin("imap.gmail.com", "smtp.gmail.com", txtLoginBox.Text, txtPassword.Text);
            Hide();
            if (Cancel_Click != null)
            {
                Cancel_Click(this, e);
            }
        }
Beispiel #6
0
        private void lbListFolders()
        {
            EmailClient Client = EmailFactory.GetEmailClient();

            String[] folders;

            try { folders = Client.ListFolders(); }
            catch (Exception e) { folders = new String[0]; }

            lbEmails.Items.Clear();
            foreach (string s in folders)
            {
                lbEmails.Items.Add(s);
            }
            folderMode = true;
        }
Beispiel #7
0
        private void BtnRefresh_Click(object sender, EventArgs e)
        {
            if (!refreshing)
            {
                //refreshing = true;

                EmailClient Client = EmailFactory.GetEmailClient();
                Client.retrieveMail();
                Messages = Client.getMailHistory();
                refreshMessages(lbEmails);
                //refreshing = false;

                //Thread thread = new Thread(refresh);
                //thread.IsBackground = true;
                //thread.Start(this);
            }
        }