ImapDownloadEntireMessage Method
Completely downloads the specified message from the server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public MailMessage DownloadEntireMessage(
	long messageIndex,
	bool indexIsUid


Type: SystemInt64
The ordinal position or UID of the message in the currently selected folder (for ordinal message numbers, can be negative, i.e. -1 denotes the last e-mail in the folder).
Type: SystemBoolean
If true, messageIndex is treated as UID; otherwise, as ordinal message number.

Return Value

Type: MailMessage
On success, a MailMessage object containing the entire message, including the message header, all the body parts and attachments; otherwise, a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.

If more than one message is downloaded, it's recommended to use DownloadEntireMessages(String, Boolean) method when possible, since it is capable of downloading multiple messages in a batch.

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

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

This sample downloads the first message from an inbox on an IMAP4 server, saves it as index.htm file, and also saves the embedded pictures and other linked objects, making it possible to open index.htm file in a browser and have the message being correctly displayed (including all the graphics, styles, etc).
using System;
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;

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

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

        // Save message as C:\Temp\index.htm
        MailMessage msg = imp.DownloadEntireMessage(1, false);
        msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml;

        // Disconnect from the server.
See Also