SendMessage Method

Send an e-mail message to one or more recipients.

Syntax

object.SendMessage( [Sender] [, Recipient] [, Message] [, Options] )

The SendMessage method syntax has the following parts:

Part Description
object An object expression that evaluates to an InternetMail object.
sender A string which specifies the e-mail address of the sender.
recipient A string which specifies one or more recipient e-mail addresses.
message A string which specifies a complete message, including headers.
options A long integer which specifies one or more options.

Return Type

Integer

Settings

The settings for Options are:

Value Constant Description
1 mailOptionImplicitSSL This option specifies that an implicit SSL session should be established with the mail server and prevents the use of a command which is used to negotiate an explicit SSL connection. This option should only be used if it is required.
4 mailOptionAuthLogin Specifies that the user must be authenticated to the mail server before the message is delivered. This option should only be used if a relay server supports AUTH LOGIN and requires authentication.
&HF0000 mailOptionNotify Notify the sender of the delivery status of the message, if the server supports delivery status notification. This option is a combination of the mailNotifySuccess, mailNotifyFailure, mailNotifyDelay and mailReturnHeaders options.
&H10000 mailNotifySuccess If the mail server supports delivery status notification, this causes a message to be returned to the sender once it has been successfully delivered.
&H20000 mailNotifyFailure If the mail server supports delivery status notification, this causes a message to be returned to the sender if it could not be delivered.
&H40000 mailNotifyDelay If the mail server supports delivery status notification, this causes a message to be returned to the sender if delivery has been delayed.
&H80000 mailReturnHeaders If the mail server supports delivery status notification, this causes a message to be returned which contains the headers of the message that was sent.
&H100000 mailReturnMessage If the mail server supports delivery status notification, this causes a message to be returned which contains the complete message that was sent.

Remarks

The SendMessage method sends the specified message to one or more recipients. This method can be used in a number of different ways, depending on the arguments specified by the caller.

The optional Sender argument identifies the sender of the message and must be a standard Internet e-mail address. If this argument is omitted, then the address specified by the From property will be used.

The optional Recipient argument specifies one or more recipients of the message. If this argument is omitted, then the addresses listed in the Bcc, Cc and To properties will be used to determine the recipients of the message.

The optional Message argument specifies a complete e-mail message that will be delivered. This must be a properly formatted message that conforms to the standards for Internet e-mail. If this argument is omitted, then the current message is sent. If this argument is specified, but the sender and recipient properties are omitted, then the message will be parsed and the addresses will be automatically determined by the values of the From, Cc and To header fields. Note that specifying a message argument does not change the current message.

The Options argument specifies one or more options for sending the message. If this argument is omitted, the value of the Options property will be used instead.

For each recipient listed, either as an argument to the method or in the message itself, the SendMessage method will determine the appropriate mail exchange server and deliver the message to that user. If the RelayServer and RelayPort properties are defined, then all messages will be relayed through that specific server, regardless of the recipient address. Note that the Secure property and related options only affects connections to relay mail servers. See the RelayServer and RelayPort properties for additional information.

If a relay server is being used, it may require authentication before accepting any messages for delivery. To enable authentication, specify the mailOptionAuthLogin option, either as an argument or by setting the Options property. Prior to calling the SendMessage method, the UserName and Password properties should be set to the values that will be used to authenticate the session. If the server does not support authentication, or the user name or password is invalid, an error will be returned. Note that authentication is only performed if a relay server is used, otherwise the option is ignored.

This method will return a value of zero if the action was successful. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

See Also

Bcc Property, Cc Property, From Property, Options Property, RelayPort Property, RelayServer Property, Secure Property, To Property


Copyright © 2008 Catalyst Development Corporation. All rights reserved.