示例#1
0
文件: emails.cs 项目: WooZoo86/Tallus
        // Helping methods for Pop3 Client user Interface

        private void ReceiveEmails()
        {
            try
            {
                Email_Client.Pop3Client pop_client = new Email_Client.Pop3Client();
                pop_client.Pop3Server = this.PopServer.Text;
                pop_client.Pop3Port   = Convert.ToInt32(this.PopPort.Text);
                pop_client.UserName   = this.PopUserName.Text;
                pop_client.Password   = this.PopPassword.Text;
                this.EnableDisableConnectButton(false);

                pop_client.ConnectionEstablishing += new Email_Client.ConnectEventHandler(this.pop_ConnectionEstablishing);
                pop_client.ConnectionEstablished  += new Email_Client.ConnectEventHandler(this.pop_ConnectionEstablished);
                pop_client.AuthenticationBegan    += new Email_Client.AuthenticateEventHandler(this.pop_AuthenticationBegan);
                pop_client.AuthenticationFinished += new Email_Client.AuthenticateEventHandler(this.pop_AuthenticationFinished);
                pop_client.StartedDataReceiving   += new Email_Client.DataReceivingEventHandler(this.pop_StartedDataReceiving);
                pop_client.EndedDataReceiving     += new Email_Client.DataReceivingEventHandler(this.pop_EndedDataReceiving);
                pop_client.Disconnected           += new Email_Client.DisconnectEventHandler(this.pop_Disconnected);

                this.pop = pop_client;

                pop_client.Connect();
                this.EnableDisableDisconnectButton(true);
                pop_client.GetMailBoxDetails();   //it sets the TotalEmails and TotalEmailSize properties

                if (pop_client.TotalEmails >= 1)
                {
                    this.UpdateStatusBar("Retrieving Emails");
                    this.FillInboxListView(pop_client);
                    this.UpdateStatusBar("Email Client");
                }
                else
                {
                    this.UpdateStatusBar("Email Client");
                    MessageBox.Show(this, "No email message exists in the inbox!.", "Email Client", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Email_Client.SmtpClientException err)
            {
                MessageBox.Show(this, err.ErrorMessage, "Email Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.UpdateStatusBar("Email Client");
                this.EnableDisableConnectButton(true);
                this.EnableDisableDisconnectButton(false);
            }
        }
示例#2
0
文件: emails.cs 项目: WooZoo86/Tallus
        private void FillInboxListView(Email_Client.Pop3Client obj)
        {
            ArrayList sender = new ArrayList();
            ArrayList subject = new ArrayList();
            ArrayList date = new ArrayList();
            ArrayList size = new ArrayList();
            DateTime  date_time; string temp = "";

            this.MailMessages.Items.Clear();

            for (int i = 1; i <= obj.TotalEmails; i++)
            {
                string emailHeader = obj.FetchEmailTop(i, 0);
                sender.Add(obj.From);
                subject.Add(obj.Subject);
                try
                {
                    date_time = DateTime.Parse(obj.Date);
                    temp      = date_time.ToString("D");
                    date.Add(temp);
                }
                catch (Exception)
                {
                    date.Add(obj.Date);
                }

                size.Add(obj.GetMailSize(i));
            }

            for (int j = 0; j < sender.Count; j++)
            {
                ListViewItem item = new ListViewItem();

                item.Text = sender[j].ToString();
                item.SubItems.Add(subject[j].ToString());
                item.SubItems.Add(date[j].ToString());
                item.SubItems.Add(size[j].ToString());

                this.InsertItem(item);
            }
        }