VB .NET SMS Script

Send SMS with VB .net SMS Script

VB .net SMS messaging is one of the services we offer. Here we'll show you how to use our SMS gateway in VB .net. Take the SMS VB .net script code below to send SMS via Developers' Central. Simply register for an account, and you will automatically receive 100 FREE SMS credits to try our service.

GET Request Example
Imports System.Net

Partial Class SendSMSHttpVB
   Inherits System.Web.UI.Page

   Protected Sub BtnSend_Click(sender As Object, e As System.EventArgs) Handles BtnSend.Click
       Dim myReq As HttpWebRequest = CType(WebRequest.Create("https://www.smsgatewayhub.com/rest/services/sendSMS/sendGroupSms?AUTH_KEY=yourauthkey&message=" + txtmsg.Text + "&senderId=DEMOOS&routeId=1&mobileNos=" + txtMobile.Text + "&smsContentType=English"), System.Net.HttpWebRequest)
       Dim myResp As HttpWebResponse = CType(myReq.GetResponse(), HttpWebResponse)
       Dim respStreamReader As System.IO.StreamReader = New System.IO.StreamReader(myResp.GetResponseStream())

       Dim responseString As String = respStreamReader.ReadToEnd()
       respStreamReader.Close()
       myResp.Close()
   End Sub
End Class
POST (XML) Request Example
Imports System.Net
Imports System.IO

Partial Class SendSMSXMLVB
    Inherits System.Web.UI.Page

    Protected Sub BtnSend_Click(sender As Object, e As System.EventArgs) Handles BtnSend.Click
        Dim api_url As String = "https://www.smsgatewayhub.com/rest/services/sendSMS/sendGroupSmsXmlApi"
        Dim xmls As String = "" +
                     "YourAuthkey" +
                     "" + txtmsg.Text + "" +
                     "DEMOOS" +
                     "1" +
                     "" + txtMobile.Text + "" +
                     "english"

        postXMLData(api_url, xmls)

        ' "signature" +

        ' "20/07/2017 08:45" +
        '""
    End Sub

    Public Function postXMLData(ByVal destinationUrl As String, ByVal requestXml As String) As String
        Dim request As HttpWebRequest = CType(WebRequest.Create(destinationUrl), HttpWebRequest)
        Dim bytes() As Byte
        bytes = System.Text.Encoding.ASCII.GetBytes(requestXml)
        request.ContentType = "application/xml; encoding='utf-8'"
        request.ContentLength = bytes.Length
        request.Method = "POST"
        Dim requestStream As Stream = request.GetRequestStream()
        requestStream.Write(bytes, 0, bytes.Length)
        requestStream.Close()
        Dim response As HttpWebResponse
        response = CType(request.GetResponse(), HttpWebResponse)
        If response.StatusCode = HttpStatusCode.OK Then
            Dim responseStream As Stream = response.GetResponseStream()
            Dim responseStr As String = New StreamReader(responseStream).ReadToEnd()
            Return responseStr
        End If

        Return Nothing
    End Function
End Class

Parameter Name with Description

Parameter Name Data Type Description
AUTH_KEY * Alphanumeric Login Authentication Key (unique for every user)
message * Text Enter your message
senderId * Text SenderId, less than 6 characters
routeId * Integer Transactional=1, Promotional=2, Promotional SenderId=3
mobileNos * Integer Comma-separated list of mobile numbers
groupId * Integer Group name from MsgClub phone book
smsContentType * Text "English" or "Unicode"