You are here:
ActiveXperts.com > SMS Messaging Server > How to create a new Message > Visual Basic 5.x/6.x
Quicklinks
SMS Messaging Server is an SMS messaging framework that enables companies to send, receive and process SMS- and e-mail messages. The framework is designed support virtually any scenario where low-and high volume SMS messaging is required. Use SMS Messaging Server in the following scenarios:
SMS Messaging Server can be well integrated into VBScript environments. This document describes how the SMS Messaging Server can be integrated into VBScript projects.
Download ActiveXperts SMS Messaging Server from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Launch 'Microsoft Visual Basic' from the Start menu, and choose 'New' from the 'File Menu'. The 'New Project' dialog appears. Select 'Standard Exe' and click 'OK':
(Click on the picture to enlarge)
A new Project is created, with a blank form.
First, you must add a reference to the SMS Messaging Server Library in the project to be able to use the SMS Messaging Server objects. To do so, choose 'References...' from the 'Project' menu. In the 'References' dialog that pops up, enable the 'ActiveXperts Sms and Pager Toolkit Type Library' reference as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'References...' dialog.
Then, select the Project form and choose 'View Code' from the context menu:
(Click on the picture to enlarge)
From the Code window, select 'Form'. The Private Sub 'Form_Load()' will be displayed now. In the 'Form Load' function, create the GSM objects in the following way:
Dim objMessageDB As AXMMCFGLib.XMessageDB Dim objConstants As AXMMCFGLib.XConstants
The following code shows how to send an SMS message:
Dim objMessageDB As AXMMCFGLib.XMessageDB
Dim objConstants As AXMMCFGLib.XConstants
Private Sub Command1_Click()
objMessageDB.Open
PrintResult ("Open")
CreateSmsMessage (strRecipient)
objMessageDB.Close
End Sub
Private Sub Form_Load()
Set objMessageDB = CreateObject("AxMmServer.MessageDB")
Set objConstants = CreateObject("AxMmServer.Constants")
End Sub
Private Sub PrintResult(strFunction)
MsgBox strFunction & ", result: " & objMessageDB.LastError & " (" & objMessageDB.GetErrorDescription(objMessageDB.LastError) & ")"
End Sub
Function CreateSmsMessage(strRecipient)
Dim objMessage
' Create new message in the Message Database
Set objMessage = objMessageDB.Create
PrintResult ("Create")
If (objMessageDB.LastError <> 0) Then
CreateSmsMessage = 0
Exit Function
End If
MsgBox "Message successfully created, recordID: " & objMessage.ID
objMessage.Direction = objConstants.MESSAGEDIRECTION_OUT
objMessage.Type = objConstants.MESSAGETYPE_SMS
objMessage.Status = objConstants.MESSAGESTATUS_PENDING
objMessage.ChannelID = 0 ' First available SMS channel
objMessage.ScheduledTime = "" ' To indicate immediate schedule.
' To schedule 1 day and 2 hours in advance, specify "+1d2h0m"
' To schedule on specific date/time, specify 12/25/2005 07:30
objMessage.Recipient = TextRecipient.Text
objMessage.Body = TextMessage.Text
' Save the new values that were just assigned
objMessageDB.Save objMessage
PrintResult ("Save")
If (objMessageDB.LastError <> 0) Then
CreateSmsMessage = 0
Exit Function
End If
CreateSmsMessage = objMessage.ID
End Function