Click here to Skip to main content
11,806,350 members (65,784 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB VB.NET
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 at 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
0 Richard Deeming 205
1 Sergey Alexandrovich Kryukov 170
2 ppolymorphe 145
3 OriginalGriff 135
4 Abhinav S 120
0 OriginalGriff 3,330
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,905
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 23 Nov 2013
Copyright © CodeProject, 1999-2015
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