MailBee.NET Objects 3.1

Pop3.QuickDownloadMessages Method (String, String, String, Int32)

Downloads all the messages (entire messages or message headers only) in the inbox on the server, in a single line of code.

public static MailMessageCollection QuickDownloadMessages(
   string serverName,
   string accountName,
   string password,
   int bodyLineCount
);

Parameters

serverName
The name or IP address of the POP3 server.
accountName
The user account name on the server.
password
The password of the user account on the server.
bodyLineCount
Number of lines of a message source body to download in addition to a message source header, or -1 to download entire messages, or 0 to download message headers only.

Return Value

A MailMessageCollection object containing the downloaded messages.

Remarks

This method does not delete any messages in the inbox.

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.

Note   Static methods still require the valid license key be assigned to LicenseKey property (by either setting in in the code or in the config file such as app.config). All samples in MailBee documentation assume the license key is already set in the config file.

Exceptions

Exception TypeCondition
MailBeeExceptionAn error occurred.

Example

This sample downloads headers of all the messages in the inbox, and displays indices (ordinal positions in the inbox) of all messages which likely have any attachments.

[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).
MailMessageCollection msgs = Pop3.QuickDownloadMessages("pop.server.com",
    "login", "password", 0);
foreach (MailMessage msg in msgs)
{
    if (msg.HasAttachments)
    {
        Console.WriteLine("Message #" + msg.IndexOnServer +
            " seems to have any attachments");
    }
}
[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 msgs As MailMessageCollection = Pop3.QuickDownloadMessages("pop.server.com", _
    "login", "password", 0)
For Each msg As MailMessage In msgs
    If msg.HasAttachments Then
        Console.WriteLine("Message #" & msg.IndexOnServer & _
            " seems to have any attachments")
    End If    
Next

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | Pop3.QuickDownloadMessages Overload List | QuickDownloadMessage