Click here to Skip to main content
13,097,012 members (82,060 online)
Rate this:
Please Sign up or sign in to vote.
See more:
dear sir,
please help me i am makeing a desktop base application . in which i want to send sms to any mobile through internet service , and i have no idea how to code it.plz help me
thanks in advance.
Posted 21-Apr-13 0:57am
ThePhantomUpvoter 21-Apr-13 7:58am
Ask your provider. They should be providing you sample code on using their service.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hello, I use this library made by me, I hope this can help you, anyway if you have any problema or doubt about the code you can report to me,

So this is the code:

Imports System.IO.Ports
Imports System.IO.Ports.SerialPort
Imports System.Threading
Public Class smsclass

    Private WithEvents Serie As New SerialPort
    Private ReadThread As Thread
    Private CONTSMS As Boolean      '// Receives ">" that means that you have to write the body of the SMS
    Private ENDSMS As Boolean       '// Receive "+CMGS" that means that the SMS has been succesfully sent
    Private ERRORSMS As Boolean     '// It becomes true when an error occurred
#End Region
#Region "EVENTS"
    Public Event DataReceived(ByVal Message As String)  'Data received from the Serial port
    Public Event SMSSended(ByVal NumTelefono As String, ByVal Content As String, ByVal Id As String) 'SMS has been succesfully sent
    Public Event SMSError(ByVal Message As String)  'There was an error sending the SMS
#End Region
    'Check the Serial Port Status
    Public ReadOnly Property IsOpen() As Boolean
            If Serie.IsOpen = True Then
                IsOpen = True
                IsOpen = False
            End If
        End Get
    End Property
#End Region

    'Public Method for Open the serial Port
    Public Sub Open(ByVal PortName As String, ByVal Speed As String)
        If IsOpen = False Then
            'Serial Port configuration
            Serie.PortName = PortName
            Serie.BaudRate = Speed
            Serie.DataBits = 8
            Serie.Parity = IO.Ports.Parity.None
            Serie.Handshake = IO.Ports.Handshake.RequestToSend
            Serie.RtsEnable = True
            Serie.DtrEnable = True
            ReadThread = New Thread(AddressOf Read)
            'Open the Serial Port and Start thread to read the port serial incoming data
            Catch ex As Exception
            End Try
        End If
    End Sub
    'Method to close serial port
    Public Sub Close()
        If IsOpen = True Then
        End If
    End Sub
    'Method to Send a SMS
    Public Sub MandarSMS(ByVal ThelephoneNumber As String, ByVal Content As String, ByVal Id As String)
        '// States of the SMS progres to the initial value
        CONTSMS = False
        ENDSMS = False
        ERRORSMS = False
        If IsOpen = True Then
            Serie.WriteLine("AT+CMGS=" & ThelephoneNumber & vbCr)    '// Destinatario
            While CONTSMS = False
            End While
            If (CONTSMS = True) Then
                Serie.WriteLine(Content & vbCrLf & Chr(26))  '// SMS CONTENT
            End If
            While (ENDSMS = False)
                If ERRORSMS = True Then
                    RaiseEvent SMSError(ThelephoneNumber) 'SMS ERROR
                    Exit While
                End If
            End While
            If ENDSMS = True Then
                RaiseEvent SMSSended(ThelephoneNumber, Content, Id) 'SMS WAS SENT
            End If
            ' Restart SMS status vars
            ENDSMS = False
            CONTSMS = False
            ERRORSMS = False
        End If
    End Sub
#End Region

    'Leer Puerto Serie
    Private Sub Read()
        Dim Incoming As String = Nothing
        While Serie.IsOpen = True
            If (Serie.BytesToRead <> 0) And (IsOpen = True) Then
                While Serie.BytesToRead <> 0
                    Incoming = Serie.ReadExisting()
                    If Incoming.Contains(">") Then
                        CONTSMS = True
                    End If
                    If Incoming.Contains("+CMGS:") Then
                        ENDSMS = True
                    End If
                    If Incoming.Contains("ERROR") Then
                        ERRORSMS = True
                    End If
                    RaiseEvent DataReceived(Incoming)
                End While
            End If
        End While
    End Sub
#End Region

End Class

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 23 Nov 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100