ImapDownloadEntireMessage Method |
Completely downloads the specified message from the server.
Namespace: MailBee.ImapMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public MailMessage DownloadEntireMessage(
long messageIndex,
bool indexIsUid
)
Public Function DownloadEntireMessage (
messageIndex As Long,
indexIsUid As Boolean
) As MailMessage
Parameters
- messageIndex
- 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). - indexIsUid
- Type: SystemBoolean
If true, messageIndex is treated as UID; otherwise, as ordinal message number.
Return Value
Type:
MailMessageOn 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 Remarks 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.
Examples 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();
imp.Connect("imap.somehost.com");
imp.Login("jdoe@somehost.com", "secret");
imp.SelectFolder("INBOX");
MailMessage msg = imp.DownloadEntireMessage(1, false);
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml;
msg.SaveHtmlAndRelatedFiles(@"C:\Temp\index.htm");
imp.Disconnect();
}
}
Imports System
Imports MailBee
Imports MailBee.ImapMail
Imports MailBee.Mime
Module Sample
Sub Main()
Dim imp As New Imap
imp.Connect("imap.somehost.com")
imp.Login("jdoe@somehost.com", "secret")
imp.SelectFolder("INBOX")
Dim msg As MailMessage = imp.DownloadEntireMessage(1, False)
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
msg.SaveHtmlAndRelatedFiles("C:\Temp\index.htm")
imp.Disconnect()
End Sub
End Module
See Also