Send SMS with Visual Basic

ISendService2 interface

Contains functions and methods that enable you to send SMS Messages.

Implemented by the SendService2 class

Dim service as new EsendexLib.SendService2

Initialise method

Initialise the class with your Esendex credentials. You must call this method before you call any other on the interface.

Sub Initialise(Username As String, Password As String, Account As String, [IsServerSide])

Parameters

  • Username Your Esendex username.
  • Password Your Esendex password.
  • Account Your Esendex Account Reference.
  • IsServerSide (optional) True if the component is running within an ASP page; false or otherwise. The default is false.

SendMessage function

Sends an SMS Message to the specified Recipient using the default Account Alias and validity period.

Function SendMessage(Recipient As String, Body As String, Type As MESSAGE_TYPE) As String 

Parameters

  • Recipient The mobile number to which the Message will be sent.
  • Body The content of the Message. The maximum length depends on the value you specify for Type. It can be up to 160 characters for Text, 140 characters for Binary and SmartMessaging or 70 characters for Unicode.
  • Type The type of Message: Text, Binary, SmartMessage or Unicode.
  • Return Value: The Id of the Message assigned by Esendex.

SendMessageFull function

Sends an SMS Message to the specified recipient.

Function SendMessageFull(Originator As String, Recipient As String, Body As String, Type As MESSAGE_TYPE, ValidityPeriod As Long) As String 

Parameters

  • Originator The Alias the Message should appear to come from. This can be another mobile number or up to 11 alpha-numeric characters. With Evaluation Accounts, this parameter must be set to the Virtual Mobile Number assigned by Esendex. With Premium Rate Accounts, this parameter must be set to the Account short code.
  • Recipient The mobile number to which the Message will be sent.
  • Body The content of the Message. The maximum length depends on the value you specify for Type. It can be up to 160 characters for Text, 140 characters for Binary and SmartMessaging or 70 characters for Unicode.
  • Type The type of Message contained in Body. This can be Text, Binary, SmartMessage or Unicode.
  • ValidityPeriod The time, in hours, for which the Message is valid. You can specify zero to use the default validity period.
  • Return Value: The Id of the Message assigned by Esendex.

SendMessageMultipleRecipients function

Sends an SMS Message to the specified recipients using the default originator and validity period.

Function SendMessageMultipleRecipients (Recipients As String, Body As String, Type As MESSAGE_TYPE) As StringCollection2 

Parameters

  • Recipients A comma-separated list of mobile numbers to which the Message will be sent.
  • Body The content of the Message. The maximum length depends on the value you specify for Type. It can be up to 160 characters for Text, 140 characters for Binary and SmartMessaging or 70 characters for Unicode.
  • Type The type of Message: Text, Binary, SmartMessage or Unicode.
  • ValidityPeriod The time, in hours, for which the Message is valid. You can specify zero to use the default validity period.
  • Return Value: An IStringCollectionPtr containing the Ids of the Messages assigned by Esendex.

SendMessageMultipleRecipientsFull function

Sends an SMS Message to the specified recipient.

Function SendMessageMultipleRecipientsFull (Originator As String, Recipients As String, Body As String, Type As MESSAGE_TYPE, ValidityPeriod As Long) As StringCollection2 

Parameters

  • Originator The alias the Message should appear to come from. This can be another mobile number or up to 11 alpha-numeric characters. With Evaluation Accounts, this parameter must be set to the Virtual Mobile Number assigned by Esendex. With Premium Rate accounts, this parameter must be set to the Account short code.
  • Recipients A comma-separated list of mobile numbers to which the Message will be sent.
  • Body The content of the Message. The maximum length depends on the value you specify for Type. It can be up to 160 characters for Text, 140 characters for Binary and SmartMessaging or 70 characters for Unicode.
  • ValidityPeriod The time, in hours, for which the Message is valid. You can specify zero to use the default validity period.
  • Return Value: An collection containing the Ids of the Messages assigned by Esendex.

GetMessageStatus function

Returns the status of a previously submitted Message.

Function GetMessageStatus(MessageID as String) As MESSAGE_STATUS

Parameters

  • Message The Id of the Message whose status you want to query.
  • Return Value: The Message status. This can be Queued, Sent, Delivered or Failed.

SendMessage Sample

Once you have imported the COM component You can send a Message as follows:

Dim service as new EsendexLib.SendService2

Sub Initialise(Username As String, Password As String, Account As String, [IsServerSide])

Function SendMessage(Recipient As String, Body As String, Type As MESSAGE_TYPE) As String