ImapQuickDownloadMessage Method (String, String, String, String, Int32, Int32)
Downloads the specified message (entire message or message header only) from the specified folder on the server, in a single line of code.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public static MailMessage QuickDownloadMessage(
	string serverName,
	string accountName,
	string password,
	string folderName,
	int messageNumber,
	int bodyPreviewSize


Type: SystemString
The name or IP address of the IMAP4 server.
Type: SystemString
The user account name on the server.
Type: SystemString
The password of the user account on the server.
Type: SystemString
The full name of the folder to download the message from.
Type: SystemInt32
The ordinal position of the message in the folder, starting at 1 (can be negative, i.e. -1 denotes the last e-mail in the inbox).
Type: SystemInt32
Number of bytes of the message source body to download in addition to the message source header, or -1 to download the entire message, or 0 to download the message header only.

Return Value

Type: MailMessage
A MailMessage object containing the downloaded message.
MailBeeExceptionAn error occurred.

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.

The common use of this method is to quickly receive the message when its index in the folder is already known. For instance, QuickDownloadMessages(String, String, String, String, Int32) method was used to download headers for all messages in the folder and build the message list where the user can click a particular message to view it completely. Once the user selected the message to be viewed, the application passes its index in the message list as a value of messageNumber parameter of QuickDownloadMessage(String, String, String, String, Int32, Int32) method to download the selected message (if the message list index is zero-based, the developer should also add 1 to the messageNumber value).

Note Note
Static methods still require the valid license key to be assigned to MailBee.Global.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.

This method is not async, it's recommended (and in case of UWP platform it's mandatory) to use sync methods like DownloadEnvelopesAsync(String, Boolean, EnvelopeParts, Int32).


This sample partially downloads the first message in the inbox (the header and the first 1000 bytes of the message source body are downloaded), and displays preview of the plain-text body of the message. This may be useful if the entire message is very large, and the user wants to take a look at the beginning of the body text in order to decide whether to download the entire message.

If the message has HTML part but does not have plain-text part, the plain-text version will be generated automatically.

// 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).
MailMessage msg = Imap.QuickDownloadMessage("", "login", "password", "Inbox", 1, 1000);
msg.Parser.HtmlToPlainMode = HtmlToPlainAutoConvert.IfNoPlain;
See Also