SendMessage Method  

Send a text message to the specified mobile device.


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


An optional string value which specifies the phone number of the mobile device. This can be a standard E.164 formatted number or an unformatted number. Any extraneous whitespace, punctuation or other non-numeric characters in the string will be ignored. If this parameter is omitted, the current value of the PhoneNumber property will be used.
An optional string value that identifies the sender of the message. For messages being sent using SMTP, this should be a valid email address. If this parameter is omitted, the current value of the Sender property will be used.
An optional string value that contains the text message that will be sent. If this parameter is omitted, the current value of the Message property will be used.
An optional integer value that is reserved for future use. If it is specified, it should have a value of zero.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure. If the method fails, the value of the LastError property can be used to determine cause of the failure.


The SendMessage method is used to send a text message to the specified mobile device. This control is designed to support multiple methods of sending text messages, with the ServiceType property determining how the message is sent:


This message service sends the message through the wireless service provider's mail gateway using the SMTP protocol. However, it is important to note that many of these gateways will not accept messages from a client that is connected to them using a residential Internet service provider. If the application is being run on a system that uses a residential provider, that service provider may also block outbound connections to all mail servers other than their own. These anti-spam measures typically require that most end-user applications specify a relay mail server rather than submitting the message directly to the wireless provider's gateway.

By default, this method will attempt to automatically determine which service provider is associated with the phone number. If the service provider cannot be determined, this method will fail and return an error code. If the Provider property has been set to to the name of a specific service provider, that provider will be used to determine the gateway email address.

Because most wireless carriers in the United States and Canada must provide for wireless number portability, there is the possibility that the provider information returned may no longer correspond to the telephone number. It is recommended that you provide your end-user with the ability to specify an alternate preferred provider to use when sending the text message. For more information, refer to ProviderCount and ProviderName properties.

This method sends an HTTP query to the server to obtain information about the phone number and wireless service provider. This requires that the local system can establish a standard network connection over port 80. If the client cannot connect to the server, the method will fail and an appropriate error will be returned. The server imposes a limit on the maximum number of connections that can be established and the maximum number of requests that can be issued per minute. If this method is called multiple times over a short period, the control may also force the application to block briefly. Server responses are cached per session, so calling this method multiple times using the same phone number will not increase the request count.

See Also

Message Property, PhoneNumber Property, Provider Property, Sender Property, ServiceType Property