MailBee.NET Objects 4.0

Imap.QuickDownloadMessages Method (String, String, String, String)

Completely downloads all the messages in the specified folder on the server, in a single line of code.

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

Parameters

serverName
The name or IP address of the IMAP4 server.
accountName
The user account name on the server.
password
The password of the user account on the server.
folderName
The full name of the folder to download the messages from.

Return Value

A MailMessageCollection object containing the downloaded messages.

Remarks

This method does not delete any messages in the folder.

An account on the mail server is guaranteed to contain at least "Inbox" folder. The "Inbox" name is case-sensitive ("Inbox", "inbox", and "INBOX" are equivalent). Other folder names, however, may be case-senstive depending on the server implementation.

Since MailBee is capable of downloading multiple messages in a batch, using this method is much more efficient than calling QuickDownloadMessage method multiple times.

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 all the messages in the inbox, and displays the index (an ordinal position in the inbox) and the attachments count of each message which has any attachments.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;

// The actual code (put it into a method of your class).
MailMessageCollection msgs = Imap.QuickDownloadMessages("imap.host.com",
    "login", "password", "Inbox");
foreach (MailMessage msg in msgs)
{
    if (msg.HasAttachments)
    {
        Console.WriteLine("Message #" + msg.IndexOnServer +
            " has " + msg.Attachments.Count + " attachment(s)");
    }
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.ImapMail
Imports MailBee.Mime

' The actual code (put it into a method of your class).
Dim msgs As MailMessageCollection = Imap.QuickDownloadMessages("imap.host.com", _
    "login", "password", "Inbox")

For Each msg As MailMessage In msgs
    If msg.HasAttachments Then
        Console.WriteLine("Message #" & msg.IndexOnServer & " has " & _
            msg.Attachments.Count & " attachment(s)")
    End If
Next

See Also

Imap Class | MailBee.ImapMail Namespace | Imap.QuickDownloadMessages Overload List | QuickDownloadMessage