Completely downloads the specified message from the server.
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).
If more than one message is downloaded, it's recommended to use DownloadEntireMessages method when possible, since it is capable of downloading multiple messages in a batch.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
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).
[C#] 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.Connect("imap.somehost.com"); imp.Login("jdoe@somehost.com", "secret"); imp.SelectFolder("INBOX"); // Save message as C:\Temp\index.htm MailMessage msg = imp.DownloadEntireMessage(1, false); msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml; msg.SaveHtmlAndRelatedFiles(@"C:\Temp\index.htm"); // Disconnect from the server. imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Imports MailBee.Mime Module Sample Sub Main() Dim imp As New Imap ' Connect to the server, login and select inbox. imp.Connect("imap.somehost.com") imp.Login("jdoe@somehost.com", "secret") imp.SelectFolder("INBOX") ' Save message as C:\Temp\index.htm Dim msg As MailMessage = imp.DownloadEntireMessage(1, False) msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml msg.SaveHtmlAndRelatedFiles("C:\Temp\index.htm") ' Disconnect from the server. imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | DownloadEntireMessages | DownloadEnvelopes