Pop3DownloadEntireMessage Method
Completely downloads the specified message from the server.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public MailMessage DownloadEntireMessage(
	int index
)

Parameters

index
Type: SystemInt32
The ordinal position of the message in the inbox. It must be in the range from 1 to InboxMessageCount. Can be negative in the range from -1 to -InboxMessageCount, i.e. -1 denotes the last e-mail in the inbox.

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).
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

If more than one message is downloaded, it's recommended to use DownloadEntireMessages(Int32, Int32) method when possible, since it can operate faster if the server supports pipelining and many small messages are downloaded.

However, if you're dealing with large e-mails (more than 1MB), it's recommended to download and process them one-by-one to avoid out-of-memory issues. Also, set List flag in InboxPreloadOptions property value prior to calling Login(String, String, String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod) method. This will eliminate memory buffer re-allocations during downloading. You can also use both DownloadEntireMessage(Int32) method to download large e-mails and DownloadEntireMessages(Int32, Int32) overload to download ranges of smaller e-mails between larger ones.

Examples
This sample downloads the last message from an inbox on a POP3 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).
// 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).
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com");
pop.Login("jdoe", "secret");
MailMessage msg = pop.DownloadEntireMessage(pop.InboxMessageCount);
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml;
msg.SaveHtmlAndRelatedFiles(@"C:\Temp\index.htm");
pop.Disconnect();
See Also