Pop3DownloadMessageHeaders Method |
Downloads headers of all messages in the inbox on the server.
Namespace: MailBee.Pop3MailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntaxpublic MailMessageCollection DownloadMessageHeaders()
Public Function DownloadMessageHeaders As MailMessageCollection
Return Value
Type:
MailMessageCollectionOn success, a
MailMessageCollection object containing the downloaded message headers;
otherwise, a null reference (
Nothing in Visual Basic).
Exceptions
Remarks
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.
ExamplesThis sample downloads headers of all the messages in the mailbox, and displays
the following information for each message:
- The display name of the sender (or the e-mail address if the display name is not available)
- The display names of the recipients (or the e-mail address when the particular display name is not available)
The message information is displayed in descending order (from newer messages to older ones).
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com");
pop.Login("jdoe", "secret");
MailMessageCollection msgs = pop.DownloadMessageHeaders();
msgs.Reverse();
foreach (MailMessage msg in msgs)
{
string sender = msg.From.DisplayName;
if (sender == string.Empty)
{
sender = msg.From.Email;
}
string recipients = 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();
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Dim pop As New Pop3
pop.Connect("mail.domain.com")
pop.Login("jdoe", "secret")
Dim msgs As MailMessageCollection
msgs = pop.DownloadMessageHeaders()
msgs.Reverse()
For Each msg As MailMessage In msgs
Dim sender As String
sender = msg.From.DisplayName
If sender = String.Empty Then
sender = msg.From.Email
End If
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()
See Also