More .NET libraries
-
Rebex Mail Pack
IMAP, MS Graph, EWS, POP3, SMTP, MIME, S/MIME, MSG
-
Rebex Total Pack
All Rebex .NET libraries together
Back to feature list...
Easy-to-use API
On this page:
A typical POP3 session goes through the following steps:
- Connect to a POP3 server.
- Validate the server certificate (this is done automatically by default, but you can perform the validation yourself).
- Log in - if required, authenticate with a user name and password or using a certificate.
- Download emails, delete emails, etc.
- Disconnect.
Downloading emails using POP3
The following code downloads all emails:
// create POP3 client instance using (var pop3 = new Rebex.Net.Pop3()) { // connect to Gmail POP3 server pop3.Connect("pop.gmail.com", SslMode.Implicit); // authenticate pop3.Login(username, password); // get message list Pop3MessageCollection list = pop3.GetMessageList(); // print some info Console.WriteLine("{0} email(s) found.", list.Count); // download all messages foreach (Pop3MessageInfo info in list) { MailMessage mail = pop3.GetMailMessage(info.SequenceNumber); // do something with the mail // ... } // disconnect (required to commit delete operations) pop3.Disconnect(); }
' create POP3 client instance Using pop3 = New Rebex.Net.Pop3() ' connect to Gmail POP3 server pop3.Connect("pop.gmail.com", SslMode.Implicit) ' authenticate pop3.Login(username, password) ' get message list Dim list As Pop3MessageCollection = pop3.GetMessageList() ' print some info Console.WriteLine("{0} email(s) found.", list.Count) ' download all messages For Each info As Pop3MessageInfo In list ' do something with the mail ' ... Dim mail As MailMessage = pop3.GetMailMessage(info.SequenceNumber) Next ' disconnect (required to commit delete operations) pop3.Disconnect() End Using
Note: Although implicit SSL mode has been discouraged since 1999 (see RFC 2595) Gmail and some other providers still only supports this mode. Explicit mode should be used instead when available.
Back to feature list...