Completely downloads the messages in the specified range from the server.
On success, a MailMessageCollection containing the downloaded messages; otherwise, a null reference (Nothing in Visual Basic).
If the POP3 server supports pipelining, this method will download all the messages in a single network operation, which greatly increases performance and reduces network traffic.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample completely downloads the last 10 messages from the inbox, and displays the number of attachments for each downloaded message. MessageDownloaded event is used to track the download progress. The sample is written for a console application.
[C#] using System; using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; class Sample { // MessageDownloaded event handler. private static void OnMessageDownloaded(object sender, Pop3MessageDownloadedEventArgs e) { Console.WriteLine("Message #" + e.MessageNumber + " downloaded"); } // The actual code. static void Main(string[] args) { Pop3 pop = new Pop3(); pop.Connect("mail.domain.com"); pop.Login("jdoe", "secret"); // Subscribe to the MessageDownloaded event. pop.MessageDownloaded += new Pop3MessageDownloadedEventHandler(OnMessageDownloaded); // Download the messages. MailMessageCollection msgs = pop.DownloadEntireMessages(pop.InboxMessageCount - 9, 10); // Display some information about downloaded messages. foreach (MailMessage msg in msgs) { Console.WriteLine("Message #" + msg.IndexOnServer + " contains " + msg.Attachments.Count + " attachment(s)"); } pop.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.Pop3Mail Imports MailBee.Mime Class Sample ' MessageDownloaded event handler. Private Shared Sub OnMessageDownloaded(ByVal sender As Object, ByVal e As Pop3MessageDownloadedEventArgs) Console.WriteLine("Message #" & e.MessageNumber & " downloaded") End Sub ' The actual code. Shared Sub Main(ByVal args As String()) Dim pop As Pop3 pop.Connect("mail.domain.com") pop.Login("jdoe", "secret") ' Subscribe to the MessageDownloaded event. AddHandler pop.MessageDownloaded, AddressOf OnMessageDownloaded ' Download the messages. Dim msgs As MailMessageCollection msgs = pop.DownloadEntireMessages(pop.InboxMessageCount - 9, 10) ' Display some information about downloaded messages. For Each msg As MailMessage In msgs Console.WriteLine("Message #" & msg.IndexOnServer & _ " contains " & msg.Attachments.Count & " attachment(s)") Next pop.Disconnect() End Sub End Class
Pop3 Class | MailBee.Pop3Mail Namespace | Pop3.DownloadEntireMessages Overload List