MailBee.NET Objects 3.1

Pop3.DownloadMessageHeader Method (Int32)

Downloads the header of the specified message from the server.

public MailMessage DownloadMessageHeader(
   int index
);

Parameters

index
The ordinal position of the message in the inbox. It must be in the range 1 to InboxMessageCount.

Return Value

On success, a MailMessage object containing the downloaded message header; otherwise, a null reference (Nothing in Visual Basic).

Remarks

If more than one message header is downloaded, it's recommended to use DownloadMessageHeaders method when possible, since it can operate much faster if the server supports pipelining.

Exceptions

Exception Type Condition
MailBeeException An error occurred and ThrowExceptions is true.

Example

This sample downloads header of the last message from an inbox on a POP3 server, and prints e-mail addresses of all the recipients of this 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");
MailMessage msg = pop.DownloadMessageHeader(pop.InboxMessageCount);
EmailAddressCollection recipients = msg.GetAllRecipients();
foreach (EmailAddress address in recipients)
{
    Console.WriteLine(address.Email);
}
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")
Dim msg As MailMessage
msg = pop.DownloadMessageHeader(pop.InboxMessageCount)
Dim recipients As EmailAddressCollection
recipients = msg.GetAllRecipients()
For Each address As EmailAddress In recipients
    Console.WriteLine(address.Email)
Next
pop.Disconnect()

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | Pop3.DownloadMessageHeader Overload List | DownloadMessageHeaders