You may want to check our Rebex Mail component. It includes IMAP, SMTP, POP3 protocols and and S/MIME parser.
The POP3
does not have a concept of 'unread' messages or searchig for messages matching specific criteria. POP3
simply returns all messages in your inbox.
Using IMAP
you can instruct the IMAP server to send you just unread messages, messages which arrived since specified time, messages from specific user etc. You don't have to download it all to the client and do the filtering there.
Following code shows how to download unread messages from the Imap
server using Rebex.Net.Imap
class.
// create client, connect and log in
Imap client = new Imap();
client.Connect("imap.example.org");
client.Login("username", "password");
// select folder
client.SelectFolder("Inbox");
// get message list - envelope headers
ImapMessageCollection messages = client.Search
(
ImapSearchParameter.HasFlagsNoneOf(ImapMessageFlags.Seen)
);
// display info about each message
Console.WriteLine("UID | From | To | Subject");
foreach (ImapMessageInfo message in messages)
{
Console.WriteLine(
"{0} | {1} | {2} | {3}",
message.UniqueId,
message.From,
message.To,
message.Subject);
}
// disconnect
client.Disconnect();
Example of combining multiple search criteria follows. This will return messages from the last year larger than 100KB.
ImapMessageCollection messages = client.Search
(
ImapSearchParameter.Arrived(DateTime.Now.AddYears(-1), DateTime.Now),
ImapSearchParameter.Size(1024 * 100, Int32.MaxValue)
);
You can download the trial from rebex.net/secure-mail.net/download.aspx