How to send bulk or group sms using AT command with GSM GPRS Modem

In earlier post we discussed how to send single sms to a number. Now here i will describe how you can send bulk or group sms using asp.net web application in ajax.


We have designed a group sms web application for LPHPP intranet http://191.254.186.1/sms.aspx?mode=group&portname=COM4

This is an AJAX based .net application which uses web service and a timer control to send sms from client browser. If one client browser is busy sending the sms and another user tries to send sms then his sms will go to pending queue by generating a smsid e.g. 123. Later IT administrator may send pending sms by just changing the url like (replace parameter group with do123)
 http://191.254.186.1/sms.aspx?mode=do123&portname=COM4

This method is applicable for both pending and done sms.

The web application has two type of access to client.
1. Direct access : users who know the masterpassword can immediately send the sms from there browser.
2. Review mode: If users dont know masterpassword then they have to use "review" as masterpassword and there sms shall be submitted with pending status . Later IT admin will review and send this sms using parameterized url.

while sending the sms, web service continuously update the send/ retry status on the client screen.

Concept is
1.      1  we have a database having mobile no with their group id. Also we have another database which contain log of sent sms.
2.       2 Our web app will first retrieve the array of cellnos according to a group id and then send sms one by one using ajax. A web service is created named vinsmsservice.asmx using vinsmsservice.vb
3.     3   Use appropriate code in your aspx page to call the said service using timer control. The cell nos are sent one by one to the web service until they are sent.
4.    4   Status of SMS shall be shown in a table. Eg. Sender eid, content , time , group no and status.
5.        Authenticate user with a login wizard then sms shall be directly sent or sent to pending queue based on master password provided.]

 Here is the database sms.mdf in app_data folder


for database connection add an entry in web.config file like this


<connectionStrings>

    <add name="vinConn3" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\sms.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>


Our web app will first retrieve the array of cellnos according to a group id and then send sms one by one using ajax.

Lets start coding In app_code folder create a file named vinsmsservice.vb  and use this code






' ASPDOTNETAJAXIM - Copyright 2010 Vinod Kotiya

' http://vinodkotiya.blogspot.com



Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Data.SqlClient

Imports System.Data

Imports Microsoft.VisualBasic

Imports System.IO.Ports

Imports System.Threading





<WebService(Namespace:="http://www.vinodkotiya.com/")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

ScriptService()> _

Public Class vinsmsservice

    Inherits System.Web.Services.WebService

    ' vinod kotiya , www.vinodkotiya.com



    Shared readNow As New AutoResetEvent(False)

    Shared port As SerialPort



    <WebMethod()> _

    Public Function sendSMS(ByVal cell As String, ByVal message As String, ByVal portname As String) As String

        ' will return something with DONE or ERROR or RETRY or PENDING

        Dim log As String = "Port opened
"

        Try

            '"Enter the port name your phone is connected to 



            port = EstablishConnection(portname)

            Dim recievedData As String = ExecuteCommand("AT", 300)



            If recievedData.Contains("+CME") Then

                log = log + "
RETRY Busy sending previous message "
+ recievedData

                Exit Try   'move to finally

            Else

                log = log + " Modem Free
"
+ recievedData

            End If

            recievedData = ExecuteCommand(" AT+CREG?", 300)



            If recievedData.Contains("0,2") Then

                log = log + "
PENDING No Network "
+ "
"
+ recievedData

                Exit Try  'Return log + "
ERROR No Network "

            ElseIf recievedData.Contains("0,1") Then

                log = log + "
Network Login "
+ "
"
+ recievedData

            End If



            recievedData = ExecuteCommand("AT+CMGF=1", 300)

            log = log + "
"
+ recievedData

            '"Enter the phone number you want to send message to:  

            Dim phoneNumber As [String] = cell '"+919411103810"

            Dim command As [String] = "AT+CMGS=""" & phoneNumber & """"





            recievedData = ExecuteCommand(command, 300)

            log = log + "
"
+ recievedData



            '   "Enter the message you want to send

            '    command = message & Char.ConvertFromUtf32(26) & vbCr

            command = message & vbCrLf & Chr(26)

            'command = "AT+CREG?"

            recievedData = ExecuteCommand(command, 300)

            log = log + "
"
+ recievedData

            If recievedData.Contains(vbLf) Then 'vbCr & vbLf & "OK" & vbCr & vbLf

                ' recievedData = "DONE Message sent successfully"

                log = log + "
DONE Message sent successfully"

            End If

            If recievedData.Contains("ERROR") Then

                Dim recievedError As String = recievedData

                recievedError = recievedError.Trim()

                ' recievedData = "Following ERROR occured while sending the message " & recievedError

                log = log + "
Following ERROR occured while sending the message "
& recievedError

            End If





        Catch ex As Exception

            log = log + "
"
+ "ERROR Message: " & ex.Message.Trim()



        Finally

            If port IsNot Nothing Then

                port.Close()

                RemoveHandler port.DataReceived, New SerialDataReceivedEventHandler(AddressOf DataReceived)

                port = Nothing

                log = log + "
Port has been closed succesfully"



            Else

                log = log + "
ERROR Port has been already open by some application."



            End If



        End Try

        '  Application("modemlock") = 0  'modem can be used now

        Return log

    End Function

    <WebMethod()> _

    Private Function ExecuteCommand(ByVal command As String, ByVal timeout As Integer) As String

        port.DiscardInBuffer()

        port.DiscardOutBuffer()

        readNow.Reset()

        port.Write(command & vbCr)

        Dim recieved As String = receive(timeout)

        Return recieved

    End Function

    <WebMethod()> _

    Private Function receive(ByVal timeout As Integer) As String

        Dim buffer As String = String.Empty

        Do

            If readNow.WaitOne(timeout, False) Then

                Dim t As String = port.ReadExisting()

                buffer += t

            End If

        Loop While Not buffer.EndsWith(vbCr & vbLf & "OK" & vbCr & vbLf) AndAlso Not buffer.EndsWith(vbCr & vbLf & "> ") AndAlso Not buffer.Contains("ERROR")

        'Loop While Not buffer.Contains("OK") AndAlso Not buffer.EndsWith(">") AndAlso Not buffer.Contains("ERROR")

        Return buffer

    End Function

    <WebMethod()> _

    Private Function EstablishConnection(ByVal portName As String) As SerialPort

        Dim port As New SerialPort()

        port.PortName = portName

        port.BaudRate = 115200

        port.DataBits = 8

        port.StopBits = StopBits.One

        port.Parity = Parity.None

        port.ReadTimeout = 300

        port.WriteTimeout = 300

        ' port.Encoding = Encoding.GetEncoding("iso-8859-1")

        AddHandler port.DataReceived, New SerialDataReceivedEventHandler(AddressOf DataReceived)

        port.Open()

        port.DtrEnable = True

        port.RtsEnable = True

        Return port

    End Function

    <WebMethod()> _

    Private Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)

        If e.EventType = SerialData.Chars Then

            readNow.[Set]()

        End If

    End Sub

    <WebMethod()> _

    Public Function logSMS(ByVal eid As String, ByVal message As String, ByVal groupid As String, ByVal requesttime As String) As String

        Dim query As String



        query = " insert into smslog (requestby, message, requesttime, groupid, status) " & _

 " VALUES  (  " & _

  "'" & Replace(eid, "'", "''") & "', " & _

                "'" & Replace(message, "'", "''") & "', " & _

                                 "'" & Replace(requesttime, "'", "''") & "', " & _

                                  "" & groupid & ", " & _

                               "'" & Replace("pending", "'", "''") & "') "

        If executeQuerydb3(query) Then

            Return " SMS queued
"

        Else

            Return "   Unable to queue SMS
"
+ query

        End If

    End Function

    <WebMethod()> _

    Public Function updateSMSstatus(ByVal requesttime As String, ByVal statusratio As String, ByVal status As String) As String

        Dim query As String

        query = " update smslog set  successratio = '" & statusratio & "' , status = '" & status & "' where requesttime = '" & requesttime & "' "



        If executeQuerydb3(query) Then

            Return " SMS status updated
"

        Else

            Return "   Unable to update SMS status
"
+ query

        End If

    End Function

    <WebMethod()> _

    Public Function getGroupCellNos(ByVal groupid As String) As String()

        Dim cellnos() As String



        Using connection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("vinConn3").ConnectionString)

            Dim sqlComm As SqlCommand

            Dim sqlReader As SqlDataReader

            Dim dt As New DataTable()

            Dim i As Integer = 0





            Try

                'connection.Close()

                connection.Open()

                sqlComm = New SqlCommand("select cell from usergroup where groupid = " + groupid, connection)  ' fname + ' ' + lname AS name

                sqlReader = sqlComm.ExecuteReader()

                dt.Load(sqlReader)

                ReDim cellnos(dt.Rows.Count)

                While i < dt.Rows.Count

                    cellnos(i) = dt.Rows(i).Item("cell").ToString

                    'temp = temp + dt.Rows(i).Item("cell").ToString



                    i = i + 1

                End While

                sqlComm.Dispose()

                connection.Close()

                Return cellnos



            Catch e As Exception



                connection.Close()

                ' cellnos(0) = "Databse fail: " + e.Message

                Return {"ERROR Databse fail: " + e.Message} 'cellnos

            End Try



        End Using



    End Function

    <WebMethod()> _

    Public Function getGroupIdwithMessage(ByVal smsid As String) As String

        'return groupid logtime and  message seperated by hash#

        Dim temp As String



        Using connection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("vinConn3").ConnectionString)

            Dim sqlComm As SqlCommand

            Dim sqlReader As SqlDataReader

            Dim dt As New DataTable()







            Try

                'connection.Close()

                connection.Open()

                sqlComm = New SqlCommand("select groupid, message, requesttime from smslog where smsid = " + smsid, connection)  ' fname + ' ' + lname AS name

                sqlReader = sqlComm.ExecuteReader()

                dt.Load(sqlReader)



                If dt.Rows.Count = 1 Then

                    temp = dt.Rows(0).Item("groupid").ToString + "#" + dt.Rows(0).Item("requesttime").ToString + "#" + dt.Rows(0).Item("message").ToString

                Else

                    temp = "ERROR: smsid not found"

                End If

                sqlComm.Dispose()

                connection.Close()

                Return temp



            Catch e As Exception



                connection.Close()

                ' cellnos(0) = "Databse fail: " + e.Message

                Return "ERROR Databse fail: " + e.Message

            End Try



        End Using



    End Function

    <WebMethod()> _

    Private Function executeQuerydb3(ByVal mysql As String) As Boolean



        'Create Connection String

        'Dim DBConn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\intradb.mdf;Integrated Security=True;User Instance=True")

        Using connection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("vinConn3").ConnectionString)

            Dim sqlComm As SqlCommand

            Dim sqlReader As SqlDataReader





            Try

                'connection.Close()

                connection.Open()

                sqlComm = New SqlCommand(mysql, connection)

                sqlReader = sqlComm.ExecuteReader()

                'Add Insert Statement

                sqlComm.Dispose()



                connection.Close()

                executeQuerydb3 = True





            Catch exp As Exception

                'lbldebug.Text = exp.Message

                connection.Close()

                executeQuerydb3 = False



            End Try



        End Using



    End Function

    <WebMethod()> _

    Public Sub rebindGridView3(ByVal query As String, ByVal gridViewControl As GridView)

        'Binds Paging/Sorting GridView with data from the specified query

        ' Bind GridView to current query & always store ur query into session("currentquery") before calling

        ' reason is whenever page indexed changed or sort.. then it will show data from currentquery



        Using connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("vinConn3").ConnectionString)



            Dim sqlComm As SqlCommand

            Dim sqlReader As SqlDataReader

            Dim dt As New DataTable()

            Dim dataTableRowCount As Integer

            Try

                connection.Open()

                sqlComm = New SqlCommand(query, connection)

                sqlReader = sqlComm.ExecuteReader()

                dt.Load(sqlReader)

                dataTableRowCount = dt.Rows.Count



                If dataTableRowCount > 0 Then

                    gridViewControl.DataSource = dt

                    gridViewControl.DataBind()

                End If

                sqlComm.Dispose()

                connection.Close()

                sqlReader.Close()

            Catch e As Exception

                'lblDebug.text = e.Message



                connection.Close()

            End Try





            connection.Close()

        End Using

    End Sub



    '    2. Using the HyperTerminal



    'Hint :: By developing your AT commands using HyperTerminal, it will be easier for you to develop your actual program codes in VB, C, Java or other platforms.



    'Go to START\Programs\Accessories\Communications\HyperTerminal (Win 2000) to create a new connection, eg. "My USB GSM Modem". Suggested settings ::



    ' - COM Port :: As indicated in the T-Modem Control Tool

    ' - Bits per second :: 115200 ( or slower )

    ' - Data Bits : 8

    ' - Parity : None

    ' - Stop Bits : 1

    ' - Flow Control : Hardware



    'You are now ready to start working with AT commands. Type in "AT" and you should get a "OK", else you have not setup your HyperTerminal correctly. Check your port settings and also make sure your GSM modem is properly connected and the drivers installed.



    '3. Initial setup AT commands



    'We are ready now to start working with AT commands to setup and check the status of the GSM modem.



    'AT       Returns a "OK" to confirm that modem is working

    'AT+CPIN="xxxx"         To enter the PIN for your SIM ( if enabled )

    'AT+CREG? A "0,1" means logged in reply confirms your modem is connected to GSM network

    'AT+CSQ   Indicates the signal strength, 31.99 is maximum.

    '4. Sending SMS using AT commands



    'We suggest try sending a few SMS using the Control Tool above to make sure your GSM modem can send SMS before proceeding. Let's look at the AT commands involved ..



    'AT+CMGF=1       To format SMS as a TEXT message

    'AT+CSCA="+xxxxx"       Set your SMS center's number. Check with your provider.

    'To send a SMS, the AT command to use is AT+CMGS ..



    'AT+CMGS="+yyyyy"

    '> Your SMS text message here



    'The "+yyyyy" is your receipent's mobile number. Next, we will look at receiving SMS via AT commands.



    '5. Receiving SMS using AT commands



    'The GSM modem can be configured to response in different ways when it receives a SMS.



    'a) Immediate - when a SMS is received, the SMS's details are immediately sent to the host computer (DTE) via the +CMT command



    'AT+CMGF=1       To format SMS as a TEXT message

    'AT+CNMI=1,2,0,0,0      Set how the modem will response when a SMS is received

    'When a new SMS is received by the GSM modem, the DTE will receive the following ..

    '    Example: Receive SMS



    'A SMS will be stored in the GSM modem / module and being send via RS232 to the peripherals. The  peripherals have to send commands to the GSM unit to receive SMS and to erase SMS from the  SIM card in order to clean memory.



    '+CMTI:"SM",x    X stands for the memory number of received SMS

    'AT+CMGR=X[Enter]    Read SMS on memory number X

    'AT+CMGD=X[Enter]    Erase SMS on memory number X

    '+CMT :  "+61xxxxxxxx" , , "04/08/30,23:20:00+40"    'This the text SMS message sent to the modem



    'Your computer (DTE) will have to continuously monitor the COM serial port, read and parse the message.



    'b) Notification - when a SMS is recieved, the host computer ( DTE ) will be notified of the new message. The computer will then have to read the message from the indicated memory location and clear the memory location.



    'AT+CMGF=1       To format SMS as a TEXT message

    'AT+CNMI=1,1,0,0,0      Set how the modem will response when a SMS is received

    'When a new SMS is received by the GSM modem, the DTE will receive the following ..



    '+CMTI: "SM",3   Notification sent to the computer. Location 3 in SIM memory

    'AT+CMGR=3      AT command to send read the received SMS from modem

    'The modem will then send to the computer details of the received SMS from the specified memory location ( eg. 3 ) ..



    '+CMGR: "REC READ","+61xxxxxx",,"04/08/28,22:26:29+40"

    'This is the new SMS received by the GSM modem



    'After reading and parsing the new SMS message, the computer (DTE) should send a AT command to clear the memory location in the GSM modem ..



    'AT+CMGD=3    To clear the SMS receive memory location in the GSM modem



    'If the computer tries to read a empty/cleared memory location, a +CMS ERROR : 321 will be sent to the computer.

    '    Important Commands

    'Note: The answers for networks and field strength can be delayed for several seconds.

    'ATZ;E[Enter]

    'Echo OFF

    'ATZ;E1[Enter]

    'Echo ON

    'AT+CSQ[Enter]

    'Show field strength. Field strength in dBm = -112 dBm+(2*X).  When X gets bigger, then the field strength is higher. -104 dBm is the lowest value for a voice  call. A data calls willfaulty because the noise is to high.

    'AT+CREG?[Enter]

    'Answer 0,x (X=2=log off, X=1=log in, X=0=don´t know) please  refer to manual for further infos

    'AT+COPS?[Enter]

    'Shows which GSM operators is active.

    '0,2,26201= T-Mobile  availiable

    'AT+COPS=?[Enter]

    'Shows all available networks





    ' CMS ERROR's (GSM Network related codes)

    '    Error       Description

    'CMS ERROR: 1    Unassigned number

    'CMS ERROR: 8    Operator determined barring

    'CMS ERROR: 10   Call bared

    'CMS ERROR: 21   Short message transfer rejected

    'CMS ERROR: 27   Destination out of service

    'CMS ERROR: 28   Unindentified subscriber

    'CMS ERROR: 29   Facility rejected

    'CMS ERROR: 30   Unknown subscriber

    'CMS ERROR: 38   Network out of order

    'CMS ERROR: 41   Temporary failure

    'CMS ERROR: 42   Congestion

    'CMS ERROR: 47   Recources unavailable

    'CMS ERROR: 50   Requested facility not subscribed

    'CMS ERROR: 69   Requested facility not implemented

    'CMS ERROR: 81   Invalid short message transfer reference value

    'CMS ERROR: 95   Invalid message unspecified

    'CMS ERROR: 96   Invalid mandatory information

    'CMS ERROR: 97   Message type non existent or not implemented

    'CMS ERROR: 98   Message not compatible with short message protocol

    'CMS ERROR: 99   Information element non-existent or not implemente

    'CMS ERROR: 111  Protocol error, unspecified

    'CMS ERROR: 127  Internetworking , unspecified

    'CMS ERROR: 128  Telematic internetworking not supported

    'CMS ERROR: 129  Short message type 0 not supported

    'CMS ERROR: 130  Cannot replace short message

    'CMS ERROR: 143  Unspecified TP-PID error

    'CMS ERROR: 144  Data code scheme not supported

    'CMS ERROR: 145  Message class not supported

    'CMS ERROR: 159  Unspecified TP-DCS error

    'CMS ERROR: 160  Command cannot be actioned

    'CMS ERROR: 161  Command unsupported

    'CMS ERROR: 175  Unspecified TP-Command error

    'CMS ERROR: 176  TPDU not supported

    'CMS ERROR: 192  SC busy

    'CMS ERROR: 193  No SC subscription

    'CMS ERROR: 194  SC System failure

    'CMS ERROR: 195  Invalid SME address

    'CMS ERROR: 196  Destination SME barred

    'CMS ERROR: 197  SM Rejected-Duplicate SM

    'CMS ERROR: 198  TP-VPF not supported

    'CMS ERROR: 199  TP-VP not supported

    'CMS ERROR: 208  D0 SIM SMS Storage full

    'CMS ERROR: 209  No SMS Storage capability in SIM

    'CMS ERROR: 210  Error in MS

    'CMS ERROR: 211  Memory capacity exceeded

    'CMS ERROR: 212  Sim application toolkit busy

    'CMS ERROR: 213  SIM data download error

    'CMS ERROR: 255  Unspecified error cause

    'CMS ERROR: 300  ME Failure

    'CMS ERROR: 301  SMS service of ME reserved

    'CMS ERROR: 302  Operation not allowed

    'CMS ERROR: 303  Operation not supported

    'CMS ERROR: 304  Invalid PDU mode parameter

    'CMS ERROR: 305  Invalid Text mode parameter

    'CMS ERROR: 310  SIM not inserted

    'CMS ERROR: 311  SIM PIN required

    'CMS ERROR: 312  PH-SIM PIN required

    'CMS ERROR: 313  SIM failure

    'CMS ERROR: 314  SIM busy

    'CMS ERROR: 315  SIM wrong

    'CMS ERROR: 316  SIM PUK required

    'CMS ERROR: 317  SIM PIN2 required

    'CMS ERROR: 318  SIM PUK2 required

    'CMS ERROR: 320  Memory failure

    'CMS ERROR: 321  Invalid memory index

    'CMS ERROR: 322  Memory full

    'CMS ERROR: 330  SMSC address unknown

    'CMS ERROR: 331  No network service

    'CMS ERROR: 332  Network timeout

    'CMS ERROR: 340  No +CNMA expected

    'CMS ERROR: 500  Unknown error

    'CMS ERROR: 512  User abort

    'CMS ERROR: 513  Unable to store

    'CMS ERROR: 514  Invalid Status

    'CMS ERROR: 515  Device busy or Invalid Character in string

    'CMS ERROR: 516  Invalid length

    'CMS ERROR: 517  Invalid character in PDU

    'CMS ERROR: 518  Invalid parameter

    'CMS ERROR: 519  Invalid length or character

    'CMS ERROR: 520  Invalid character in text

    'CMS ERROR: 521  Timer expired

    'CMS ERROR: 522  Operation temporary not allowed

    'CMS ERROR: 532  SIM not ready

    'CMS ERROR: 534  Cell Broadcast error unknown

    'CMS ERROR: 535  Protocol stack busy

    'CMS ERROR: 538  Invalid parameter

    '    CME ERROR's (GSM Equipment related codes)



    ' Error   Description

    'CME ERROR: 0    Phone failure

    'CME ERROR: 1    No connection to phone

    'CME ERROR: 2    Phone adapter link reserved

    'CME ERROR: 3    Operation not allowed

    'CME ERROR: 4    Operation not supported

    'CME ERROR: 5    PH_SIM PIN required

    'CME ERROR: 6    PH_FSIM PIN required

    'CME ERROR: 7    PH_FSIM PUK required

    'CME ERROR: 10   SIM not inserted

    'CME ERROR: 11   SIM PIN required

    'CME ERROR: 12   SIM PUK required

    'CME ERROR: 13   SIM failure

    'CME ERROR: 14   SIM busy

    'CME ERROR: 15   SIM wrong

    'CME ERROR: 16   Incorrect password

    'CME ERROR: 17   SIM PIN2 required

    'CME ERROR: 18   SIM PUK2 required

    'CME ERROR: 20   Memory full

    'CME ERROR: 21   Invalid index

    'CME ERROR: 22   Not found

    'CME ERROR: 23   Memory failure

    'CME ERROR: 24   Text string too long

    'CME ERROR: 25   Invalid characters in text string

    'CME ERROR: 26   Dial string too long

    'CME ERROR: 27   Invalid characters in dial string

    'CME ERROR: 30   No network service

    'CME ERROR: 31   Network timeout

    'CME ERROR: 32   Network not allowed, emergency calls only

    'CME ERROR: 40   Network personalization PIN required

    'CME ERROR: 41   Network personalization PUK required

    'CME ERROR: 42   Network subset personalization PIN required

    'CME ERROR: 43   Network subset personalization PUK required

    'CME ERROR: 44   Service provider personalization PIN required

    'CME ERROR: 45   Service provider personalization PUK required

    'CME ERROR: 46   Corporate personalization PIN required

    'CME ERROR: 47   Corporate personalization PUK required

    'CME ERROR: 48   PH-SIM PUK required

    'CME ERROR: 100  Unknown error

    'CME ERROR: 103  Illegal MS

    'CME ERROR: 106  Illegal ME

    'CME ERROR: 107  GPRS services not allowed

    'CME ERROR: 111  PLMN not allowed

    'CME ERROR: 112  Location area not allowed

    'CME ERROR: 113  Roaming not allowed in this location area

    'CME ERROR: 126  Operation temporary not allowed

    'CME ERROR: 132  Service operation not supported

    'CME ERROR: 133  Requested service option not subscribed

    'CME ERROR: 134  Service option temporary out of order

    'CME ERROR: 148  Unspecified GPRS error

    'CME ERROR: 149  PDP authentication failure

    'CME ERROR: 150  Invalid mobile class

    'CME ERROR: 256  Operation temporarily not allowed

    'CME ERROR: 257  Call barred

    'CME ERROR: 258  Phone is busy

    'CME ERROR: 259  User abort

    'CME ERROR: 260  Invalid dial string

    'CME ERROR: 261  SS not executed

    'CME ERROR: 262  SIM Blocked

    'CME ERROR: 263  Invalid block

    'CME ERROR: 772  SIM powered down

End Class







Now create another file vinsmsservice.asmx in root of your site to use the earlier created web service

              <%@ WebService Language="VB" CodeBehind="~/App_Code/vinsmsservice.vb" Class="vinsmsservice" %>


Lets start designing sms.aspx page. first we will write vb.net code behind. Here my code uses user login authentication so you have to work it out for yourself or if you directly want to run it then uncomment following lines in page load  
  '   Session("eid") = "009383"
            'Session("name") = "Vinod K"


also access the sms.aspx page like this with portname and mode parameter.

<a href="sms.aspx?mode=group&portname=COM4">Group Messaging System</a>


Imports System.Threading

Partial Class sms
    Inherits System.Web.UI.Page

    ' if error comes then kill the asp.net development server. may be accessing the com port
    Shared vinread As New AutoResetEvent(False)
    Shared failednos As Integer = 0
    Shared totalnos As Integer = 0 'no of cell to send sms
    Shared workingno As String = "" ' currently sending sms on this no
    Shared workingmessage As String = "" ' currently sending this message


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            'this will be executed only first time any event happen on web page
            ' If IsNothing(Request.Params("mode")) Then
            lblCell.Visible = False
            txtCell.Visible = False
            Timer1.Enabled = False
           
            If Not IsNothing(Request.Params("mode")) Then
                Session("mode") = Request.Params("mode") '    'mono or group or smsid
                '   lblCellno.Text = Request.Params("mode")
            Else
                Session("mode") = "group"
            End If
            If Not IsNothing(Request.Params("portname")) Then
                Session("portname") = Request.Params("portname")
                ' lblCellno.Text = lblCellno.Text + Request.Params("portname")
            Else
                Session("portname") = "COM3"
            End If

            If Not Session("mode") = "mono" And Not Session("mode") = "group" Then
                ' if pending smsid has been given
                If IsNumeric(Session("mode")) Then
                    '' means smsid has been given
                    lblCellno.Text = sendPendingSMS(Session("mode"))

                End If
            End If

            '
            '   Session("eid") = "009383"
            'Session("name") = "Vinod K"
            'txtSMS.Text = Now.Second.ToString + Rnd(1000).ToString + " Random sms no for group sms "

        End If

        If Not String.IsNullOrEmpty(Session("eid")) Then
            btnSend.Enabled = True
            If (FileIO.FileSystem.FileExists(Server.MapPath("~/database/pics/") + "p" + Session("eid") + ".gif")) Then
                imgUser.ImageUrl = "database\pics\p" + Session("eid") + ".gif"
            Else
                lblName.Text = "Guest: " + Request.UserHostAddress
                imgUser.ImageUrl = "database\pics\anonymous.gif"
            End If
            lblName.Text = Session("name")
            lblEid.Text = "Eid : " + Session("eid")
            lblDept.Text = Session("dept") + "
Log Out "

        Else
            btnSend.Enabled = False
            imgUser.ImageUrl = "database\pics\anonymous.gif"
            lblDept.Text = " Log in "
            lblName.Text = "Guest: " + Request.UserHostAddress
            lblLogin.Text = " Please Authorize First Click here to Log in "
        End If

        Session("CurrentQuery") = "SELECT LEFT(message, 70) + '...' AS message,smsid, convert(varchar, requesttime, 104) as requesttime1, requestby, successratio, groupid, status from smslog ORDER BY status DESC, requesttime DESC"
        Dim vinservice As vinsmsservice = New vinsmsservice
        vinservice.rebindGridView3(Session("CurrentQuery"), gvSMSlog)
    End Sub


    Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
        'Dim SMSEngine As New vinsms("COM3")
        'SMSEngine.Open()
        'lblStatus.Text = "starting
"
        'lblStatus.Text = SMSEngine.SendSMS(txtSMS.Text, "+919411103810")
        lblExe.Text = "Execution"
        lblSent.Text = ""
        Dim vinservice As New vinsmsservice
        Dim logtime As DateTime = Now
        'SMSEngine.Close()
        If Session("mode") = "mono" Then
            lblCell.Visible = True
            txtCell.Visible = True
            If txtSMS.Text.Length < 160 Then

              

                If txtMasterPassword.Text = "123456" Or txtMasterPassword.Text = "ntpc123" Then
                    '##### first log the sms
                    lblStatus.Text = vinservice.logSMS(Session("eid"), txtSMS.Text.Trim, "0", logtime.ToString)

                    '#####now send sms
                    lblCellno.Text = "Working On: " + txtCell.Text
                    Dim temp As String = vinservice.sendSMS(txtCell.Text, txtSMS.Text.Trim, Session("portname"))
                    lblStatus.Text = lblStatus.Text + temp

                    '#####now update sms status
                    If temp.Contains("ERROR") Then  'to get here always use CAPS ERROR

                        lblStatus.Text = lblStatus.Text + " Unable to send message to " + txtCell.Text + "
"
                        lblStatus.Text = lblStatus.Text + vinservice.updateSMSstatus(logtime.ToString, "0/1", "pending")
                        lblCellno.Text = lblCellno.Text + "
UnSent: "
+ txtCell.Text


                    Else
                        lblStatus.Text = lblStatus.Text + " Message sent succesfully to " + txtCell.Text + "
"
                        lblStatus.Text = lblStatus.Text + vinservice.updateSMSstatus(logtime.ToString, "1/1", "done")
                        lblCellno.Text = lblCellno.Text + "
Sent: "
+ txtCell.Text

                    End If
                ElseIf txtMasterPassword.Text = "review" Then
                    lblStatus.Text = lblStatus.Text + vinservice.logSMS(Session("eid"), txtSMS.Text.Trim, "0", logtime.ToString)
                    vinservice.rebindGridView3(Session("CurrentQuery"), gvSMSlog)
                    lblCellno.Text = " Thanks, Your SMS has been sent in queue, and will be delivered later after review. "
                    'queue function
                Else
                    lblCellno.Text = " You have not provided any Master password If dont have any. Use ''review'' as master password to send message in queue. "
                    '    Response.Write("")

                End If

            Else
                lblCellno.Text = "Your SMS length has " + txtSMS.Text.Length.ToString + " characters which exceeds limit of 160 Characters.
plz make it short.
"
            End If

            ' repeat same for group SMS
        ElseIf Session("mode") = "group" Then
          
            If txtSMS.Text.Length < 160 Then  ' check SMS length
                If rblGroup.SelectedIndex >= 0 Then  ' check group is selected or not

                    If txtMasterPassword.Text = "ntpc123" Or txtMasterPassword.Text = "789101112" Then
                        Dim temp As String = sendGroupSMS(rblGroup.SelectedValue.ToString, txtSMS.Text.Trim, Session("portname"))
                        lblStatus.Text = lblStatus.Text + temp
                        lblExe.Text = " Wait.. Sending.. "
                        Session("CurrentQuery") = "SELECT LEFT(message, 35) + '...' AS message,smsid, convert(varchar, requesttime, 104) as requesttime1, requestby, successratio, groupid, status from smslog ORDER BY status DESC, requesttime DESC"


                    ElseIf txtMasterPassword.Text = "review" Then

                        '##### first log the sms
                        lblStatus.Text = vinservice.logSMS(Session("eid"), txtSMS.Text.Trim, rblGroup.SelectedValue.ToString, logtime.ToString)
                        vinservice.rebindGridView3(Session("CurrentQuery"), gvSMSlog)
                        lblCellno.Text = " Thanks, Your SMS has been sent in queue, and will be delivered later after review. "
                    Else
                        lblCellno.Text = " You have not provided any Master password If dont have any. Use ''review'' as master password to send message in queue. "
                        ' Response.Write("")

                    End If
                Else
                    lblCellno.Text = "You have not selected any Group. Please select one from the list. "
                End If    'group check ends

            Else
                lblCellno.Text = "Your SMS length has " + txtSMS.Text.Length.ToString + " characters which exceeds limit of 160 Characters.
plz make it short.
"
            End If     'sms length end
            End If
    End Sub
    Private Function sendGroupSMS(ByVal groupid As String, ByVal message As String, ByVal portname As String) As String
        Dim vinservice As New vinsmsservice
        Session("message") = message
        ''### Now get the phone no list from groupid
        Session("cellnos") = vinservice.getGroupCellNos(groupid)
        ''## check that got all the nos. from database of group
        If Session("cellnos").ToString.Contains("ERROR") Then
            Return Session("cellnos").ToString + "
Unable to retrive cell list from database. Quit"

        End If
        '##### first log the sms
        Dim logtime As DateTime = Now
        Session("logtime") = logtime

        lblStatus.Text = vinservice.logSMS(Session("eid"), message, groupid, Session("logtime").ToString)

        Session("cellnoindex") = 0
        Session("Call_Once") = True  'if true u can call for sending sms
        Session("status") = "done" ' done or pending
        Timer1.Enabled = True
        Timer1.Interval = 1000
        lblStatus.Text = ""
        lblCellno.Text = ""

        Return "Initiating Sending Process
"
    End Function
    Function sendPendingSMS(ByVal smsid As String) As String
        Dim vinservice As New vinsmsservice
        Dim temp As String
        Dim groupid As String
        '### Now get the groupid with message first
        temp = vinservice.getGroupIdwithMessage(smsid)   'return groupid logtime and  message seperated by hash#
        If temp.Contains("ERROR") Then
            Return temp  'unable to get groupid logtime and  message
        Else
            Dim arr As String() = temp.Split("#")
            groupid = arr(0)
            Session("logtime") = arr(1)
            Session("message") = arr(2)
            'Return groupid + Session("logtime") + Session("message")
            ''### Now get the phone no list from groupid
            Session("cellnos") = vinservice.getGroupCellNos(groupid)
            ''## check that got all the nos. from database of group
            If Session("cellnos").ToString.Contains("ERROR") Then
                Return Session("cellnos").ToString + "
Unable to retrive cell list from database. Quit"
            End If

            Session("cellnoindex") = 0
            Session("Call_Once") = True  'if true u can call for sending sms
            Session("status") = "done" ' done or pending
            Timer1.Enabled = True
            Timer1.Interval = 1000
            lblStatus.Text = ""
            lblCellno.Text = ""
            lblExe.Text = " Wait.. Sending.. "
            Return "Initiating Sending Process
"
        End If
    End Function

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ' Timer1.Enabled = False
        Dim vinservice As New vinsmsservice
        Dim temp As String = ""
      
        Dim cellnos() As String = Session("cellnos")



        '#####now send sms
        If Session("Call_Once") And Int(Session("cellnoindex")) < cellnos.Length - 1 Then  'And Application("modemlock") = 0
            ' Application("modemlock") = 1  'modem can't be used now
            Session("Call_Once") = False
            Dim i As Integer = Int(Session("cellnoindex"))
            temp = vinservice.sendSMS(cellnos(i), Session("message"), Session("portname"))  ' will return something with DONE or ERROR
            lblStatus.Text = lblStatus.Text + temp

            'Session("cellnoindex") =0 has been called so prepare for next one
            Session("cellnoindex") = i + 1
            lblCellno.Text = lblCellno.Text + "
Working On: "
+ cellnos(i)


            'Check status
            If temp.Contains("RETRY") Then
                Session("cellnoindex") = i
                lblStatus.Text = lblStatus.Text + " Modem Busy. Now Retry For " + cellnos(i) + "
"
                lblCellno.Text = lblCellno.Text + "
Retry "
+ cellnos(i) + ""
            ElseIf temp.Contains("PENDING") And Session("cellnoindex") = 0 Then   'when first no failed by network then quit
                Session("cellnoindex") = cellnos.Length - 1
                lblStatus.Text = lblStatus.Text + " No Network, Message Sent in queue. Try Later 
"
                lblCellno.Text = lblCellno.Text + "
No Network, Message Sent in queue. Try Later "
                failednos = cellnos.Length   ' all sms failed
                Session("status") = "pending" ' done or pending
            ElseIf temp.Contains("PENDING") Then   'when network failed in between lets try other no
                lblStatus.Text = lblStatus.Text + " No Network, when sending " + cellnos(i) + "
"
                ' count no of failed cell
                failednos = failednos + 1
                ' store no of failed cell no
                lblCellno.Text = lblCellno.Text + "
Unsent "
+ cellnos(i) + ""
            ElseIf temp.Contains("ERROR") Then  'to get here always use CAPS ERROR

                lblStatus.Text = lblStatus.Text + " Unable to send message to " + cellnos(i) + "
"
                ' count no of failed cell
                failednos = failednos + 1
                ' store no of failed cell no
                lblCellno.Text = lblCellno.Text + "
Unsent "
+ cellnos(i) + ""
              
            ElseIf temp.Contains("DONE") Then
                lblStatus.Text = lblStatus.Text + " Message sent succesfully to " + cellnos(i) + "
"
                lblCellno.Text = lblCellno.Text + "
Sent "
+ cellnos(i) + ""
           
            End If
            Session("Call_Once") = True 'now u can send other no for sms
            lblSent.Text = "Sent: " + (Int(Session("cellnoindex")) - failednos).ToString + " out of " + (cellnos.Length - 1).ToString
        ElseIf Int(Session("cellnoindex")) = cellnos.Length - 1 Then
            ''###now update the sms status
            lblStatus.Text = lblStatus.Text + vinservice.updateSMSstatus(Session("logtime"), (cellnos.Length - failednos - 1).ToString + "/" + Session("cellnoindex").ToString, Session("status"))
            Session("Call_Once") = False
            vinservice.rebindGridView3(Session("CurrentQuery"), gvSMSlog)
            lblExe.Text = " Done: " + (cellnos.Length - failednos - 1).ToString + " out of " + Session("cellnoindex").ToString + " message sent succesfully"
            Timer1.Enabled = False
        End If

    

    End Sub
    Protected Sub gvSMSlog_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvSMSlog.PageIndexChanging
        If gvSMSlog.DataSource.GetType().ToString = "System.Data.DataTable" Then
            ' gvSMSlog.DataSource = SortDataTable(gvSMSlog.DataSource, True)
            gvSMSlog.PageIndex = e.NewPageIndex
            Session("CurrentPage") = e.NewPageIndex
            gvSMSlog.DataBind()
        End If
    End Sub
    Protected Sub gvSMSlog_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvSMSlog.SelectedIndexChanged
        ' Bind current data
        '  gvSMSlog.DataSource = SortDataTable(gvSMSlog.DataSource, True)
        gvSMSlog.PageIndex = Session("CurrentPage")
        gvSMSlog.DataBind()

        ' Clear session variables
     
        Session("CurrentQuery") = Nothing

    End Sub
End Class




And finally here is the aspx code having ajax feature using timer and updatepanel to show real time sending status at client side.




DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title> LPHPP Intranettitle>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" />
  
<noscript><style type="text/css">.qmmc {width:200px !important;height:200px !important;overflow:scroll;}.qmmc div {position:relative !important;visibility:visible !important;}.qmmc a {float:none !important;white-space:normal !important;}style>noscript>
<link rel='stylesheet' type='text/css' href='quickmenu.css'/>

<script type='text/javascript' src='quickmenu.js'>script>
    <style type="text/css">
        .style9
        {
            width: 120px;
            height: 26px;
        }
        .style10
        {
            height: 44px;
        }
    style>
head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
           <Services>    <asp:ServiceReference Path="vinsmsservice.asmx" />
           Services>
 asp:ToolkitScriptManager>
     <script type="text/javascript">
         var xPos1, yPos1;
         var xPos2, yPos2;
         var prm = Sys.WebForms.PageRequestManager.getInstance();
         prm.add_beginRequest(BeginRequestHandler);
         prm.add_endRequest(EndRequestHandler);
         function BeginRequestHandler(sender, args) {
             xPos1 = $get('Panel1').scrollLeft;
             yPos1 = $get('Panel1').scrollTop;
             xPos2 = $get('Panel2').scrollLeft;
             yPos2 = $get('Panel2').scrollTop;
         }

         function EndRequestHandler(sender, args) {
             $get('Panel1').scrollLeft = xPos1;
             $get('Panel1').scrollTop = yPos1;
             $get('Panel2').scrollLeft = xPos2;
             $get('Panel2').scrollTop = yPos2;

         }
  script>
    div>
    <div id="container">
  <div id="banner">
      <asp:Label ID="lblHeader" runat="server" Font-Bold="True"
          Font-Names="Microsoft Sans Serif" Font-Size="Large" ForeColor="White"
          Text="Loharinag- Pala Hydro Power Project, NTPC Limited.">asp:Label>
  div>
 
  <div id="qm0" class="qmmc">

       <a href="departments.aspx">Departmentsa>

              <div>
             
             
              div>

       <a href="javascript:void(0)">Maila>
             <div>
                <a href="http://191.254.186.230/WebRedir.nsf">NTPC Maila>
                 <a href="departments.aspx">Search e-Mail ida>
                 <a href="http://10.0.8.220/names.nsf?ChangePassword">Change NTPC Mail Passworda>
                 <a href="http://191.254.1.220/names.nsf">Change Profilea>

            div>

       <a href="javascript:void(0)">Imp Linksa>

              <div>
<a href="dept/hr/pv.htm">Power Vision Magazinea>
              <a href="dept/hr/dop2005.pdf">DoP 2005a>
              <a href="departments.aspx?dept=HR">HR Formatsa>
              <a href="departments.aspx?dept=FINANCE">F&A Formatsa>
              <a href="http://10.0.5.2:8001/webntpc/hr_homepage_files/corp_hr_circulars.jsp">HR Circulars(CC)a>
              <a href="http://191.254.198.107/gdams/realview_new2.asp">GDAMSa>
              <a href="http://191.254.1.211:81/doctracker">DOC Trackera>
                 <a href="http://191.254.1.211:81/ipon/">IPONa>
         <a href="http://10.1.210.55/IPON/IdeaLogin.aspx">HIPONa>
         <a href="http://10.0.5.2:8001/webntpc/hr_homepage_files/transfer_list.htm">Transfer Lista>
         <a href="departments.aspx?dept=HR">Law & Actsa>
         <a href="dept/eed/elecact/elecact.html">Electricity Acta>
         <a href="departments.aspx?dept=IT">Software Downloadsa>

              div>

       <a href="javascript:void(0)">Useful Linksa>

              <div>
        <a href="HTTP://www.ntpc.co.in">NTPC Limiteda>
              <a href="http://www.google.co.in">Googlea>
              <a href="http://www.onlinesbi.com">Online SBIa>
              <a href="http://www.icicibank.com">ICICI Banka>
        <a href="http://www.bsnl.co.in">BSNLa>
              <a href="http://www.erail.in">Rail Enquirya>
              <a href="javascript:void(0)">Train/Flighta>
        <div>
        <a href="http://www.irctc.co.in">IRCTCa>
        <a href="http://www.makemytrip.com">MakemyTripa>
        <a href="http://www.cleartrip.com">Clear Tripa>
        <a href="http://www.yatra.com">Yatraa>
                      div>
              <a href="javascript:void(0)">Maila>
         <div>
         <a href="http://191.254.186.230/WebRedir.nsf">NTPC Maila>
        <a href="http://www.gmail.com">Gmaila>
        <a href="http://www.mail.yahoo.com">Yahoo!a>
        <a href="http://www.rediffmail.com">Rediffa>
      
                      div>
              div>

       <a href="javascript:void(0)">Projecta>

              <div>
              <a href="loader.aspx?requestedpage=layout">Project Layouta>
              <a href="dept/fes/dcsindex.html">Drawing Librarya>
              <a href="loader.aspx?requestedpage=activity">Ongoing Activitya>
        <a href="loader.aspx?requestedpage=milestone">Milestonesa>
              <a href="dept/fes/caindex.html">Contract Agreementsa>
        <a href="loader.aspx?requestedpage=award">Award Detailsa>
        <a href="loader.aspx?requestedpage=fotogal">Foto Gallerya>
             
              div>
        <a href="javascript:void(0)">Searcha>

              <div>
              <a href="departments.aspx">Search Employeea>
              <a href="uploader.aspx?mode=circulars">Search Circularsa>
              <a href="uploader.aspx?mode=articles">Search Articlesa>
        div>
          <a href="javascript:void(0)">e-Servicesa>
        <div>
        <a href="sms.aspx?mode=group&portname=COM4">Group Messaging Systema>
              <a href="booking.aspx">Welfare Vehicle Bookinga>
              <a href="http://191.254.186.1:3431/">Online Complaintsa>
              <a href="uploader.aspx?mode=articles">Add Circulars,News,Eventsa>
        <a href="uploader.aspx?mode=articles">Add Articlesa>
            <a href="uploader.aspx?mode=ftp">File Sharinga>
        <a href="uploader.aspx?mode=reports">Online Reporta>
        <a href="uploader.aspx?mode=zigyaasa">Zigyaasaa>
        div>

<span class="qmclear"> span>div>

<script type="text/javascript">    qm_create(0, false, 0, 50, false, false, false, false, false);script>
 <ul id="navlist">
    <li id="active"><a id="current" href="default.aspx">HOMEa>li>
    <li><a href="loader.aspx?requestedpage=erp">ERPa>li>
    <li><a href="uploader.aspx?mode=circulars">Circularsa>li>
    <li><a href="uploader.aspx?mode=articles">Articlesa>li>
     <li><a href="http://191.254.186.1:3431/">IT-Supporta>li>
   <li>  <a href="booking.aspx">e-Bookinga>li>
    <li>  <a href="sms.aspx?mode=group&portname=COM4">SMSa>li>
 <li><a href="departments.aspx">SearchEmployeea>li>
  <li><a href="loader.aspx?requestedpage=hindi">हिन्दीa>li>
    <li><a href="uploader.aspx?mode=feedback">Feedbacka>li>
      
  ul>
  <div id="sidebar-a">
    
    <h3>>>h3>
   
   
      <p><asp:Image ID="imgUser" runat="server" class="border"  alt="Loading.." />
     
             
        <center> <asp:Label ID="lblName" runat="server" Text="Guest" Font-Bold="True"
              ForeColor="#CC33FF">asp:Label>
     <br />  <asp:Label ID="lblEid" runat="server" Font-Bold="True" ForeColor="#CC33FF">asp:Label>
     <br />
        
          <asp:Label ID="lblDept" runat="server" Font-Bold="True" ForeColor="#CC33FF">asp:Label>center> p>
  div>


 <div id="vincontent">
 <h2> <span style="font-weight:bold; color:#891E18;">Group Messagingspan>
       Systemh2> <blockquote class="style1">Use This Feature to send group SMS within LPHPP. You must have a master password to send ths SMS immediately. If you dont have any then use "review" as master password and your SMS shall be sent later after review.blockquote>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
       
        <table> <tr ><td width="300px"> <fieldset><legend>Send SMSlegend> <table> <tr>
            <td class="style9">
       
                     <asp:Label ID="lblCell" runat="server" Text="Cell No:"
                        style="font-weight: 700">asp:Label>
        td> <td >      
            <asp:TextBox ID="txtCell" runat="server" BorderColor="#009900"
                BorderStyle="Solid" BorderWidth="2px" CssClass="tbox" Width="123px">+919411103810asp:TextBox>
            <br />td> tr>
            <tr> <td class="style10" >
                <strong>Master Password:strong> td> <td class="style10" >   
            <asp:TextBox ID="txtMasterPassword" runat="server" Width="171px"
                BorderColor="#009900" BorderStyle="Solid" BorderWidth="2px" CssClass="tbox"
                TextMode="Password">asp:TextBox>
                    <br />
                    <asp:Label ID="lblPwd" runat="server" ForeColor="Red"
                        Text="Default Password is "review"">asp:Label>
            <br /> td> tr>
            <tr> <td >
                <strong>Select Group: strong> td> <td> 
                    <asp:RadioButtonList ID="rblGroup" runat="server"
                RepeatDirection="Horizontal" Height="26px" Width="280px" RepeatColumns="2">
                <asp:ListItem Value="1">All Employeesasp:ListItem>
                <asp:ListItem Value="2">All HoD'sasp:ListItem>
                <asp:ListItem Value="3">IT Reportasp:ListItem>
                        <asp:ListItem Value="9">Test Groupasp:ListItem>
            asp:RadioButtonList>
             <br /> td>  tr>
            table>
       
     
            <asp:TextBox ID="txtSMS" runat="server" Height="72px" Width="300px"
                BorderColor="#009900" BorderStyle="Solid" BorderWidth="2px" CssClass="tbox"
                TextMode="MultiLine">asp:TextBox>
            <asp:Button ID="btnSend" runat="server" Text="Send SMS" BorderColor="#009900"
                BorderWidth="2px" CssClass="button" />
           
          
            <asp:Label ID="lblLogin" runat="server">asp:Label>
           
          
            fieldset>
            td>
           
            <td >   <asp:Label ID="lblExe" runat="server" Text="Execution"
                    style="font-weight: 700">asp:Label>
                <br />
                <asp:Label ID="lblSent" runat="server" ForeColor="#009900">asp:Label>
                <br />
                <asp:Panel ID="Panel1"
                    runat="server" Height="199px"
                    ScrollBars="Vertical" Width="206px">
                <asp:Label ID="lblCellno" runat="server">asp:Label>
                asp:Panel>
            td>
            <td >
                <asp:Panel ID="Panel2" runat="server" Height="217px" ScrollBars="Vertical"
                    Width="150px">
                <asp:Label ID="lblStatus" runat="server">asp:Label>
            asp:Panel>td>
            tr>
            table>
            <fieldset  Width="600px"  ><legend>SMS Loglegend>
          <asp:GridView ID="gvSMSlog" runat="server" Height="109px" PageSize="10"
              Width="600px" AllowPaging="True"
                 AutoGenerateColumns="False"
                        EmptyDataText="No records found" GridLines="None"
              BorderWidth="2px">
                        <Columns>
                             <asp:BoundField DataField="smsid"  ShowHeader="False"
                                 HeaderText="smsID" > 
                             <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                             <ItemStyle Font-Size="8pt" />
                             asp:BoundField>
                            <asp:HyperLinkField DataTextField="requestby" HeaderText="Sent By"
                                Text="requestby" DataNavigateUrlFields="requestby" Target="_blank"
                                DataNavigateUrlFormatString="departments.aspx?showemp={0}">
                              <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle ForeColor="#FF0066" Font-Size="8pt" />
                            asp:HyperLinkField>
                        <asp:BoundField DataField="message"  ShowHeader="False" HeaderText="Messgae" >
                            <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle  Font-Size="8pt" />
                            asp:BoundField>
                            <asp:BoundField DataField="requesttime1"  ShowHeader="False" HeaderText="Time" >
                            <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle Width="10%" Font-Size="8pt" />
                            asp:BoundField>
                              <asp:BoundField DataField="groupid"  ShowHeader="False" HeaderText="Group" >
                            <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle Width="4%" Font-Size="8pt" />
                            asp:BoundField>
                             <asp:BoundField DataField="status"  ShowHeader="False" HeaderText="Status" >
                            <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle Width="8%" Font-Size="8pt" />
                            asp:BoundField>
                             <asp:BoundField DataField="successratio"  ShowHeader="False" HeaderText="Sent" >
                            <HeaderStyle HorizontalAlign="Left" BackColor="#009933" ForeColor="White" />
                            <ItemStyle Width="5%" Font-Size="8pt" />
                            asp:BoundField>

                      Columns>
                     asp:GridView>
        fieldset>
            <asp:Timer ID="Timer1" runat="server">
            asp:Timer>
           
       
        ContentTemplate>
        asp:UpdatePanel>
   
    div>
    div>
    form>
body>
html>


Thats all our group sms messaging system is ready using visual web developer 2010 and vb.net code behind.

- Vinod Kotiya
www.vinodkotiya.com
cell: +919411103810


Comments

Annadanam said…
Hi, Is this your solution works in vs2010 only.
Annadanam said…
HI, i am using At commands to send sms in asp.net2.0. It's working fine.
But When i click sent message button in 2 different systems at a time. One message is going and second one is not going. It's giving error like com port access denied. If you know the error, Please let me know.

Thanks in Advance.
Vinod Kotiya said…
You should not try sending two sms from different system simultaneously. GSM modem has limitation of sending one sms at a time thats why i designed this application such that it send sms one by one. If you want then you can modify this application by adding another module which buffers the 2nd sms when modem is busy with first.

-- vinod kotiya
Annadanam said…
Hi Vinod,
Thank you very much for your reply. I am new to this concept. If i have sms option in my website. So 2 users may click at the same time. In this case what i have to do. If you have code in c#. Please send to madhu.aj@gmail.com. If
Vinod Kotiya said…
I have implemented webservices through ajax. Its obvious that two users can click simultaneously. when 2nd user click he gets the error . i have already programmed my webapp to send the second message in pending queue. I dont have c# code. But my code dosent automatically send second pending sms. its manual. but it can be programmed with a timer to check that when modem is free it starts sending 2nd sms.

-- vinod kotiya
Annadanam said…
Thanks for your response.
Annadanam said…
I am unable to find the solution for my problem. Could you please give the solution for my problem. It will be very help full to me.How to send messages in queue i.e one by one. If 2 persons clicks send button at the same time.

Thanks in advance.
Vinod Kotiya said…
Yaar its simple... You just make code to send sms .. its obvious that you will make error handling as ido just look code in to my function

_

Public Function sendSMS(ByVal cell As String, ByVal message As String, ByVal portname As String) As String


There is a code for checking modem is busy or not as follows:
port = EstablishConnection(portname)

Dim recievedData As String = ExecuteCommand("AT", 300)



If recievedData.Contains("+CME") Then

log = log + "
RETRY Busy sending previous message " + recievedData

Exit Try 'move to finally

Else

log = log + " Modem Free
" + recievedData

End If


now with this code it throws error and i know that somebody is already sending a sms and modem is busy. you just halt the second user for sometime and again call sendsms function from a timer control.
sendSMS( cell , message , portname )

Better you just gothrough my vb code once its a simple and try to understand how it works. Use some tools to get VC# code.

- vinod kotiya
Annadanam said…
Ok, Thank you very much for your co-operation.
Annadanam said…
Hi. I converted code vb to c#. But i am getting com1 access denied error again. before checking the device is busy or not code. we are using
port = EstablishConnection(portname);


In this function we are specifying port.open() method. There i am getting com1 access denied error.

Thanks in advance.
Vinod Kotiya said…
It means device is already opened somewhere. You first try to send sms using hyperterminal. i already exlained method in my post in green color comments.. If hyperterminal works then close it and your application must work.

- vinod kotiya
Unknown said…
Hi,
i am using Relance R Conect(ZTE prduct(cdma)).when i try to send sms though our application it will not send sms.while when i send 1st msg from zte software it will send,and then if i try to send sms through my application its start send msg. can u suggest e whts problem
Unknown said…
Hi,
i am using Relance R Conect(ZTE prduct(cdma)).when i try to send sms though our application it will not send sms.while when i send 1st msg from zte software it will send,and then if i try to send sms through my application its start send msg. can u suggest e whts problem
Vinod Kotiya said…
@prateek

May be there is some initialization AT command for ur device... search for that command...
Vinod Kotiya said…
This comment has been removed by the author.
Help said…
Can you tell me plz Any services are available send SMS (US,UK and also INDIA),Now i am ready to buy a SMS service,
and also how to this service integrate?
Plz give me step by step process.....
I am new this one
Unknown said…
I am working with a windows form application in C# working with AT commands to send messages to multiple phone number that are stored in an excel sheet. i have loaded the excel sheet using data grid view but i am not getting how to read all numbers from the data grid column and send the message can you please help
anubhavgupta said…
Thanks for sharing valuable information.sms script for vb dotnet