You are here:
ActiveXperts.com > SMS Messaging Server > How to create a new Message > ASP.NET (Visual Basic)
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.
You must install and configre Internet Information Services (IIS) before using SMS Messaging Server with ASP .NET. If you don't have IIS installed, use the following steps:
(Click on the picture to enlarge)
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 Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):
(Click on the picture to enlarge)
Now that a new project has been created, you must add a reference to the SMS Messaging Server API in the project in order to use the the SMS Messaging Server API objects. To do so, choose 'Add Reference...' from the 'Project' menu. In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the 'ActiveXperts SMS Messaging Server Type Library' as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'Add Reference' dialog.
On top of your code, type the following line to use the SMS Messaging Server API namespace:
Imports AXMMCFGLib
In your Main function, declare and create the following objects:
Protected objMessageDB As XMessageDB Protected objMessage As XMessage Protected objConstants As XConstant objMessageDB = New XMessageDB objConstants = New XConstants
You should not create an instance of a Message yourself; it is returned by functions like Create, FindFirstMessage, FindNextMessage and Load.
The following code shows how to send an SMS message:
Imports AXMMCFGLib
Partial Class _Default
Inherits System.Web.UI.Page
Protected objMessageDB As XMessageDB
Protected objMessage As XMessage
Protected objConstants As XConstants
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
objMessageDB = New XMessageDB
objConstants = New XConstants
objMessageDB.Open()
output.InnerHtml += "Open: ERROR #" & objMessageDB.LastError & _
" (" & objMessageDB.GetErrorDescription(objMessageDB.LastError) & ")"
output.InnerHtml += "<BR><BR>"
If (objMessageDB.LastError = 0) Then
objMessage = objMessageDB.Create()
output.InnerHtml += "Create: ERROR #" & objMessageDB.LastError & _
" (" & objMessageDB.GetErrorDescription(objMessageDB.LastError) & ")"
output.InnerHtml += "<BR><BR>" & vbCrLf
If (objMessageDB.LastError = 0) Then
output.InnerHtml += "Message Created with ID: " & objMessage.ID
output.InnerHtml += "<BR><BR>" & vbCrLf
objMessage.Direction = objConstants.MESSAGEDIRECTION_OUT
objMessage.Recipient = "+31647134225"
objMessage.Status = objConstants.MESSAGESTATUS_PENDING
objMessage.Type = objConstants.MESSAGETYPE_SMS
objMessage.Body = "Message Created with ASP.NET(VB)"
objMessageDB.Save(objMessage)
output.InnerHtml += "Save: ERROR #" & objMessageDB.LastError & _
" (" & objMessageDB.GetErrorDescription(objMessageDB.LastError) & ")"
output.InnerHtml += "<BR><BR>" & vbCrLf
End If
objMessageDB.Close()
End If
End Sub
End Class