The return value may be less than the number of bytes specified by
the cbBuffer parameter. In this case, the data has been
partially written and it is the responsibility of the client
application to send the remaining data at some later point. For
non-blocking clients, the client must wait for the next asynchronous
notification message before it resumes sending data.
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
CMailMessage class 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 to submit the message for delivery.
An alternative approach to creating a message without using
the CMailMessage class is the SubmitMessage
method. It accepts two structure parameters which define the message
contents and the connection information for the mail server. This
enables the application to compose the message and submit it for
delivery in a single method call.