downloading the email via the POP3 protocol is the easy part of the task. The protocol is quite simple and the only hard part could be advanced authentication methods if you don't want to send a clear text password over the network (and cannot use the SSL encrypted communication channel). See RFC 1939: Post Office Protocol - Version 3
and RFC 1734: POP3 AUTHentication command for details.
The hard part comes when you have to parse the received email, which means parsing MIME format in most cases. You can write quick&dirty MIME parser in a few hours or days and it will handle 95+% of all incoming messages. Improving the parser so it can parse almost any email means:
- getting email samples sent from the most popular mail clients and improve the parser in order to fix errors and RFC misinterpretations generated by them.
- Making sure that messages violating RFC for message headers and content will not crash your parser and that you will be able to read every readable or guessable value from the mangled email
- correct handling of internationalization issues (e.g. languages written from righ to left, correct encoding for specific language etc)
- Attachments and hierarchical message item tree as seen in "Mime torture email sample"
- S/MIME (signed and encrypted emails).
- and so on
Debugging a robust MIME parser takes months of work. I know, because I was watching my friend writing one such parser for the component mentioned below and was writing a few unit tests for it too ;-)
Back to the original question.
Following code taken from our POP3 Tutorial page and links would help you:
// create client, connect and log in
Pop3 client = new Pop3();
// get message list
Pop3MessageCollection list = client.GetMessageList();
if (list.Count == 0)
Console.WriteLine("There are no messages in the mailbox.");
// download the first message
MailMessage message = client.GetMailMessage(list.SequenceNumber);