The CreateMessage method begins the composition of a new
message to be submitted to the mail server for delivery. There are
several steps that must be followed when dynamically composing a
message using the CreateMessage method:
- Call the CreateMessage method to begin the message
composition. The sender email address should generally be the same
address as the one used in the "From" header field in the
message.
- Call the AddRecipient method for each recipient of the
message. These addresses are typically specified in the
"To" and "Cc" header fields in the message.
Additional addresses may also be provided which are not
specified in the email message itself. This is how one or more
blind carbon copies of a message is delivered. Most servers have a
limit on the total number of recipients that may be specified for a
single message. This limit is usually around 100 addresses.
- Call the Write method to write the contents of the
message to the data stream. The application may also choose to use
the AppendMessage method to write out a large amount of
message data.
- Call the CloseMessage method to close the message and
submit it to the mail server for delivery.
For applications that do not need to dynamically compose the
message and already have the message contents stored in a file or
memory buffer, the SendMessage method is the preferred method
of submitting a message for delivery.