Completely downloads the specified messages from the server.
On success, a MailMessageCollection containing the downloaded messages; otherwise, a null reference (Nothing in Visual Basic).
To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes topic.
This method will download all the messages in a single network operation, which greatly increases performance and reduces network traffic.
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 is a kind of overload of DownloadEnvelopes method.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
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.
[C#] 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.Connect("mail.domain.com"); imp.Login("jdoe", "secret"); imp.SelectFolder("INBOX"); // 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. imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Imports MailBee.Mime Module Sample ' EnvelopeDownloaded event handler. Private Sub OnEnvelopeDownloaded(ByVal sender As Object, _ ByVal e As ImapEnvelopeDownloadedEventArgs) Console.WriteLine("Message #" & e.MessageNumber & " downloaded") End Sub Sub Main(ByVal args As String()) Dim imp As New Imap ' Connect to the server, login and select inbox. imp.Connect("mail.domain.com") imp.Login("jdoe", "secret") imp.SelectFolder("INBOX") ' Subscribe to the EnvelopeDownloaded event. AddHandler imp.EnvelopeDownloaded, AddressOf 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. Dim msgs As MailMessageCollection = _ imp.DownloadEntireMessages((imp.MessageCount - 9).ToString() & ":*", False) ' Display some information about downloaded messages. For Each msg As MailMessage In msgs Console.WriteLine("Message #" & msg.IndexOnServer & " contains " & _ msg.Attachments.Count & " attachment(s)") Next ' Disconnect from the server. imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace