Downloads headers of all messages in the inbox on the server.
On success, a MailMessageCollection object containing the downloaded message headers; 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 downloads headers of all the messages in the mailbox, and displays the following information for each message:
[C#] // To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; // The actual code (put it into a method of your class). Pop3 pop = new Pop3(); pop.Connect("mail.domain.com"); pop.Login("jdoe", "secret"); // Download headers of all the messages in the inbox. MailMessageCollection msgs = pop.DownloadMessageHeaders(); // Reverse the order of the elements to make newer messages appear first in the collection. msgs.Reverse(); foreach (MailMessage msg in msgs) { // Get the sender. string sender = msg.From.DisplayName; if (sender == string.Empty) { sender = msg.From.Email; } // Get the list of recipients. string s = string.Empty; foreach (EmailAddress address in msg.GetAllRecipients()) { string recipient = address.DisplayName; if (recipient == string.Empty) { recipient = address.Email; } if (recipients == string.Empty) { recipients += recipient; } else { recipients += ", " + recipient; } } Console.WriteLine("Message #" + msg.IndexOnServer + " was originally sent by " + sender + " to " + recipients); } pop.Disconnect();
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Pop3Mail Imports MailBee.Mime ' The actual code (put it into a method of your class). Dim pop As New Pop3 pop.Connect("mail.domain.com") pop.Login("jdoe", "secret") ' Download headers of all the messages in the inbox. Dim msgs As MailMessageCollection msgs = pop.DownloadMessageHeaders() ' Reverse the order of the elements to make newer messages appear first in the collection. msgs.Reverse() For Each msg As MailMessage In msgs ' Get the sender. Dim sender As String sender = msg.From.DisplayName If sender = String.Empty Then sender = msg.From.Email End If ' Get the list of recipients. Dim recipients As String recipients = String.Empty For Each address As EmailAddress In msg.GetAllRecipients() Dim recipient As String = address.DisplayName If recipient = String.Empty Then recipient = address.Email End If If recipients = String.Empty Then recipients = recipients & recipient Else recipients = recipients & ", " & recipient End If Next Console.WriteLine("Message #" & msg.IndexOnServer & " was originally sent by " & sender & " to " & recipients) Next pop.Disconnect()
Pop3 Class | MailBee.Pop3Mail Namespace | Pop3.DownloadMessageHeaders Overload List