示例#1
0
        private void GetMessageList()
        {
            lvMessages.Items.Clear();

            for (int i = 1; i <= imap41.CurrentMailBox.ExistsMessages; i++)
            {
                try
                {
                    imap41.RetrieveHeader(i, mailMessage1);

                    ListViewItem item = lvMessages.Items.Add(i.ToString());
                    item.SubItems.Add(mailMessage1.Subject);
                    item.SubItems.Add(mailMessage1.From.FullAddress);

                    MailMessageFlags flags = imap41.GetMessageFlags(i);
                    string           s     = "";

                    if ((flags & MailMessageFlags.Answered) == MailMessageFlags.Answered)
                    {
                        s += "Answered,";
                    }
                    if ((flags & MailMessageFlags.Flagged) == MailMessageFlags.Flagged)
                    {
                        s += "Flagged,";
                    }
                    if ((flags & MailMessageFlags.Deleted) == MailMessageFlags.Deleted)
                    {
                        s += "Deleted,";
                    }
                    if ((flags & MailMessageFlags.Seen) == MailMessageFlags.Seen)
                    {
                        s += "Seen,";
                    }
                    if ((flags & MailMessageFlags.Draft) == MailMessageFlags.Draft)
                    {
                        s += "Draft,";
                    }
                    if ((flags & MailMessageFlags.Recent) == MailMessageFlags.Recent)
                    {
                        s += "Recent,";
                    }

                    item.SubItems.Add(s);
                }
                catch (TcpClientError)
                {
                    ListViewItem item = lvMessages.Items.Add(i.ToString());
                    item.SubItems.Add("(bad message)");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                }
            }
        }
示例#2
0
        private void FillMessages()
        {
            lvMessages.Items.Clear();
            ClearMessage();

            for (int i = 1; i <= imap41.CurrentMailBox.ExistsMessages; i++)
            {
                imap41.RetrieveHeader(i, mailMessage1);

                ListViewItem item = lvMessages.Items.Add(mailMessage1.Subject);
                item.SubItems.Add(mailMessage1.From.FullAddress);
                item.SubItems.Add(mailMessage1.Date.ToString());
                item.SubItems.Add(imap41.GetMessageSize(i).ToString());
                item.SubItems.Add(i.ToString());
            }
        }