SmtpCreateMessage
INT SmtpCreateMessage(
HCLIENT hClient  
LPCTSTR lpszSender,  
DWORD dwMessageSize,  
DWORD dwReserved  
);

The SmtpCreateMessage function creates a new message for delivery.

Parameters

hClient
Handle to the client session.
lpszSender
A pointer to a null-terminated string which specifies the e-mail address of the user sending the message. This typically corresponds to the address in the From header of the message, but it is not required that they be the same.
dwMessageSize
An unsigned long integer which specifies the size of the message in bytes. If the size of the message is unknown, this value should be zero. This parameter is ignored if the server does not support extended features. If the message size is larger than what the server will accept, this function will fail. Most Internet Service Providers impose a limit on the size of an e-mail message, typically between 5 and 10 megabytes.
dwReserved
A reserved parameter. This value should be zero.

Return Value

If the function succeeds, the return value is zero. If the function fails, the return value is SMTP_ERROR. To get extended error information, call SmtpGetLastError.

Remarks

The SmtpCreateMessage function 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 for delivery:

  1. Call the SmtpCreateMessage function to begin the message composition. The sender e-mail address should generally be the same address as the one used in the "From" header field in the message.
  2. Call the SmtpAddRecipient function 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 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.
  3. Call the SmtpWrite function to write the contents of the message to the data stream. The application may also choose to use the SmtpAppendMessage function to write out a large amount of message data, or write the contents of a file to the data stream.
  4. Call the SmtpCloseMessage function 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 SmtpSendMessage function is the preferred method of submitting a message for delivery.

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csmtpav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

SmtpAddRecipient, SmtpAppendMessage, SmtpCloseMessage, SmtpSendMessage, SmtpWrite


Copyright © 2008 Catalyst Development Corporation. All rights reserved.