The Write method sends the data in buffer to the
server. If the connection is buffered, as is typically the case,
the data is copied to the send buffer and control immediately returns
to the program. If the control is blocking, the application will wait
until the data can be sent. If the control is non-blocking and the
write fails because it could not send all of the data to the server,
the OnWrite event will be fired when the server can accept
data again.
If the Write method is used to send the message
contents to the server, the application must first call the
CreateMessage method to specify the sender and the length of
the message, followed by one or more calls to the AddRecipient
method to specify each recipient of the message. When all of the
message text has been submitted to the server, the application must
call the CloseMessage method.
The message text is filtered by the Write
method, and it will automatically normalize end-of-line character
sequences to ensure the message meets the protocol requirements. The
message itself must be in a standard RFC 822 or multi-part MIME
message format, or the server may reject the message. Binary data,
such as file attachments, should always be encoded. The
MailMessage control can be used to compose and export a
message in the correct format, which can then be submitted to the server.
It is recommended that most applications use the
SendMessage method, which submits the message in a single
method call.