Download the Class file.

Imports Microsoft.VisualBasic
Imports System.Text
Imports System.IO
Imports System.Web
Imports System.Net
 
Public Class SMS24x
 
    Public Function SendMessage() As String
 
        If Me.UserName = "" Or Me.Password = "" Then
            MsgBox("Please supply both a username and password to this function")
        Else
 
            Me.GateWayURL = "http://www.24x.com/sendsms/sendsms.aspx?user=" & Me.UserName & "&password=" & Me.Password & "&smsto=" & Me.SMSTO & "&smsfrom=" & Me.smsFrom & "&smsmsg=" & Me.smsMessage
            Dim objUTFEncode As New UTF8Encoding
            Dim arrRequest As Byte()
            Dim objStreamReq As Stream
            Dim objStreamRes As StreamReader
            Dim objHttpRequest As HttpWebRequest
            Dim objHttpResponse As HttpWebResponse
            Dim objUri As New Uri(Me.GateWayURL)
            objHttpRequest = WebRequest.Create(objUri)
            objHttpRequest.KeepAlive = False
            objHttpRequest.Timeout = 40000
            objHttpRequest.Method = "POST"
            objHttpRequest.ContentType = "application/x-www-form-urlencoded"
            arrRequest = objUTFEncode.GetBytes(Me.smsMessage)
            objHttpRequest.ContentLength = arrRequest.Length
            objStreamReq = objHttpRequest.GetRequestStream()
            objStreamReq.Write(arrRequest, 0, arrRequest.Length)
            objStreamReq.Close()
            'Get response
            Try
                objHttpResponse = objHttpRequest.GetResponse() 'Must be 200 status
                objStreamRes = New StreamReader(objHttpResponse.GetResponseStream(), Encoding.ASCII)
                Me.Response = objStreamRes.ReadToEnd()
                objStreamRes.Close() 'Careful we dont lock up.
                Return Me.Response
            Catch ex As WebException
                Me.Response = ex.Message.ToString
                Return Me.Response
            End Try
        End If
        Return ""
    End Function
 
    Private _userName As String = ""
    Private _password As String = ""
    Private _gatewayURL As String = ""
    Private _response As String = ""
    Private _smsTo As String = ""
    Private _smsFrom As String
    Private _smsMessage As String = ""
 
    Public Property smsMessage() As String
 
        Get
 
            Return _smsMessage
 
        End Get
 
        Set(ByVal Value As String)
 
            _smsMessage = Value
 
        End Set
 
    End Property
 
    Public Property smsFrom() As String
 
        Get
 
            Return _smsFrom
 
        End Get
 
        Set(ByVal Value As String)
 
            _smsFrom = Value
 
        End Set
 
    End Property
 
    Public Property SMSTO() As String
 
        Get
 
            Return _smsTo
 
        End Get
 
        Set(ByVal Value As String)
 
            _smsTo = Value
 
        End Set
 
    End Property
 
    Public Property GateWayURL() As String
 
        Get
 
            Return _gatewayURL
 
        End Get
 
        Set(ByVal Value As String)
 
            _gatewayURL = Value
 
        End Set
 
    End Property
 
    Private Function responseCodes(ByVal responseCode As String) As String
 
        responseCode = Trim(responseCode)
 
        Select Case responseCode
 
            Case "01"
 
                Return "Username or password incorrect."
 
            Case "02"
 
                Return "smsTo missing."
 
            Case "03"
 
                Return "smsFrom missing."
 
            Case "04"
 
                Return "Smsmsg missing."
 
            Case "05"
 
                Return "Smstype invalid."
 
            Case "06"
 
                Return "Send Date greater that one month in the future."
 
            Case "07"
 
                Return "Invalid operator code."
 
            Case "08"
 
                Return "Operator required for Nokia logo."
 
            Case "09"
 
                Return "Insufficient credits."
 
            Case "10"
 
                Return "More than 100 mobile numbers in then smsTo field"
 
            Case "11"
 
                Return "WAP Push combined field length greater than 90 characters"
 
            Case "00"
 
                Return "Success"
 
        End Select
        Return ""
 
    End Function
 
    Public Property Response() As String
 
        Get
 
            Return responseCodes(_response)
        End Get
 
        Set(ByVal Value As String)
            _response = Value
 
        End Set
 
    End Property
 
    Public Property Password() As String
 
        Get
 
            Return _password
 
        End Get
 
        Set(ByVal Value As String)
 
            _password = Value
 
        End Set
 
    End Property
 
    Public Property UserName() As String
 
        Get
 
            Return _userName
 
        End Get
 
        Set(ByVal Value As String)
 
            _userName = Value
 
        End Set
 
    End Property
 
    Public Sub New()
 
    End Sub
 
    Private Function URLEncode(ByVal strData) As String
        Dim I, strTemp, strChar, strOut, intAsc
        strTemp = Trim(strData)
 
        For I = 1 To Len(strTemp)
            strChar = Mid(strTemp, I, 1)
 
            intAsc = Asc(strChar)
 
            If (intAsc >= 48 And intAsc <= 57) Or (intAsc >= 97 And intAsc <= 122) Or (intAsc >= 65 And intAsc <= 90) Then
                strOut = strOut & strChar
            Else
                strOut = strOut & "%" & Hex(intAsc)
            End If
        Next
        Return strOut
    End Function
 
End Class