SmtpSendMessage
INT SmtpSendMessage(
HCLIENT hClient,  
LPCTSTR lpszFrom,  
LPCTSTR lpszRecipient,  
LPVOID lpvMessage,  
DWORD dwMessageSize,  
DWORD dwOptions  
);

The SmtpSendMessage function sends the contents of a file or memory buffer to the specified recipients.

Parameters

hClient
Handle to the client session.
lpszFrom
Pointer to a null-terminated string which specifies the e-mail address of the sender.
lpszRecipient
Pointer to a null-terminated string which specifies the recipient of the message. Multiple recipients may be specified by separating each address with a comma.
lpvMessage
Pointer to a buffer which contains the message to be delivered, or a pointer to the name of the file which contains the data to be written to the data stream. The use of this parameter depends on the value of the dwOptions parameter.
dwMessageSize
An unsigned long integer which specifies the length of the message in bytes.
dwOptions
Specifes the source of the message data that is to be written to the data stream; it may be one of the following values:
Constant
Description
SMTP_MESSAGE_MEMORY The lpvMessage parameter specifies a pointer to an array of characters. If the value of dwMessageSize is zero, then it is assumed that the data is a null-terminated string.
SMTP_MESSAGE_HGLOBAL The lpvMessage parameter specifies an HGLOBAL which contains the data to be written to the data stream. If the value of the dwMessageSize parameter is zero, then the data is assumed to be null-terminated.
SMTP_MESSAGE_FILE The lpvMessage parameter specifies a pointer to null-terminated string which contains the name of a file. The file is opened and the contents of the file are written to the data stream. The value of the dwMessageSize parameter is ignored when this option is specified.
SMTP_MESSAGE_CLIPBOARD The lpvMessage and dwMessageSize parameters are ignored. The current contents of the clipboard are written to the data stream.

Return Value

If the function succeeds, the return value is the result code from the server. If the function fails, the return value is SMTP_ERROR. To get extended error information, call SmtpGetLastError.

Remarks

The SmtpSendMessage function is used to send the contents of a memory buffer, file or the system clipboard to the specified recipients. The message must be in the standard format as described in RFC 822.

This protocol is only concerned with the delivery of a message and not its contents. Header fields in the message are not parsed to determine the recipients. This recipient parameter should be a concatenation of all recipients, including carbon copies and blind carbon copies, with each address separated with a comma.

This function will cause the current thread to block until the complete message has been delivered, a timeout occurs or the operation is canceled. During the transfer, the SMTP_EVENT_PROGRESS event will be periodically fired, enabling the application to update any user interface controls. Event notification must be enabled, either by calling SmtpEnableEvents, or by registering a callback function using the SmtpRegisterEvent function.

To determine the current status of the transaction while it is in progress, use the SmtpGetTransferStatus function.

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

SmtpAppendMessage, SmtpCloseMessage, SmtpGetTransferStatus


Copyright © 2008 Catalyst Development Corporation. All rights reserved.