MailBee.NET Objects 3.1

Pop3.DownloadEntireMessage Method 

Completely downloads the specified message from the server.

public MailMessage DownloadEntireMessage(
   int index
);

Parameters

index
The ordinal position of the message in the inbox. It must be in the range 1 to InboxMessageCount.

Return Value

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).

Remarks

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

Exceptions

Exception Type Condition
MailBeeException An error occurred and ThrowExceptions is true.

Example

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).

[C#]
// 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();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

' The actual code (put it into a method of your class).
Dim pop As New Pop3
pop.Connect("mail.domain.com")
pop.Login("jdoe", "secret")
Dim msg As MailMessage
msg = pop.DownloadEntireMessage(pop.InboxMessageCount)
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
msg.SaveHtmlAndRelatedFiles("C:\Temp\index.htm")
pop.Disconnect()

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | DownloadEntireMessages