SocketTools .NET Edition

SmtpClient.AppendMessage Method (Byte[], Int32)

Append text to the current message being composed.

[Visual Basic]
Overloads Public Function AppendMessage( _
   ByVal buffer As Byte(), _
   ByVal length As Integer _
) As Boolean
[C#]
public bool AppendMessage(
   byte[] buffer,
   int length
);

Parameters

buffer
A byte array which specifies the data to be appended to the message.
length
An integer value which specifies the maximum number of bytes of data to append to the message. This value cannot be larger than the size of the buffer specified by the caller

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 AppendMessage method appends the specified text to the current message. This method will cause the current thread to block until the article 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.

This method is useful for composing a message where the application needs to dynamically create the header, followed by a large amount of text. The message contents should be text, with each line terminated with a carriage return and linefeed character. Not all mail servers support sending 8-bit characters, so the message contents may need to be encoded if it uses anything other than standard US ASCII. To append binary data, it should be encoded using either the uucode or base64 (MIME) algorithms. It is recommended that you use the SocketTools.MailMessage class to manage file attachments and other complex message types.

See Also