SocketTools .NET Edition

ImapClient.GetMessage Method (Int32, Int32, Byte[], Int32, ImapSections)

Retrieve a message from the server and return the contents in a byte array.

[Visual Basic]
Overloads Public Function GetMessage( _
   ByVal messageId As Integer, _
   ByVal messagePart As Integer, _
   ByVal buffer As Byte(), _
   ByRef length As Integer, _
   ByVal options As ImapSections _
) As Boolean
[C#]
public bool GetMessage(
   int messageId,
   int messagePart,
   byte[] buffer,
   ref int length,
   ImapSections options
);

Parameters

messageId
Number of article to retrieve from the server. This value must be greater than zero. The first message in the mailbox is message number one.
messagePart
An integer value that specifies the message part that should be retrieved. A value of zero specifies that the complete message should be returned. If the message is a multipart MIME message, message parts start with a value of one.
buffer
A byte array that the message data will be stored in.
length
An integer value passed by reference which specifies the maximum number of bytes of data to read. This value cannot be larger than the size of the buffer specified by the caller. When the method returns, this parameter will be updated with the actual number of bytes copied into the array.
options
An ImapSections enumeration value which specifies which section of the message to return.

Return Value

This method returns a boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

The GetMessage method is used to retrieve a message from the server and copy it into a local buffer. This method will cause the current thread to block until the message transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

See Also