ImapDownloadEntireMessages Method
Completely downloads the specified messages from the server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public MailMessageCollection DownloadEntireMessages(
	string messageIndexSet,
	bool indexIsUid


Type: SystemString
A message sequence string containing ordinal message numbers or UIDs. Can be composed manually or using ToString.
Type: SystemBoolean
If true, messageIndexSet is treated as a sequence of UIDs; otherwise, as a sequence of ordinal message numbers.

Return Value

Type: MailMessageCollection
On success, a MailMessageCollection containing the downloaded messages; otherwise, a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.

To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes(String, Boolean) topic.

This method will download all the messages in a single network operation, which greatly increases performance and reduces network traffic.

To make messages SEEN upon downloading, change SetSeenForEntireMessages property value to true before calling this method.

Note Note
To track downloading messages, EnvelopeDownloaded event should be used. There is no MessageDownloaded event since mail messages are actually downloaded within envelopes. Once an envelope is downloaded, the mail message data is extracted from it. Generally speaking, DownloadEntireMessages(String, Boolean) is a kind of overload of DownloadEnvelopes(String, Boolean, EnvelopeParts, Int32, String, String) method.

For advanced purposes, use DownloadEnvelopes(String, Boolean, EnvelopeParts, Int32, String, String). With IMAP envelopes, you can get extra flags, and more.

This console sample completely downloads the last 10 messages from the inbox, and displays the number of attachments for each downloaded message. EnvelopeDownloaded event is used to track the download progress.
using System;
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;

class Sample
    // EnvelopeDownloaded event handler.
    private static void OnEnvelopeDownloaded(object sender,
        ImapEnvelopeDownloadedEventArgs e)
        Console.WriteLine("Message #" + e.MessageNumber + " downloaded");

    static void Main(string[] args)
        Imap imp = new Imap();

        // Connect to the server, login and select inbox.
        imp.Login("jdoe", "secret");

        // Subscribe to the EnvelopeDownloaded event.
        imp.EnvelopeDownloaded +=
            new ImapEnvelopeDownloadedEventHandler(OnEnvelopeDownloaded);

        // Download the last 10 messages. Note: this sample does not check
        // if there are less than 10 messages in the inbox. See sample code
        // in DownloadEnvelopes(string, bool) overload for more information.
        MailMessageCollection msgs = imp.DownloadEntireMessages(
            (imp.MessageCount - 9).ToString() + ":*", false);

        // Display some information about downloaded messages.
        foreach (MailMessage msg in msgs)
            Console.WriteLine("Message #" + msg.IndexOnServer +
                " contains " + msg.Attachments.Count + " attachment(s)");

        // Disconnect from the server.
See Also