hi, im new to vb.net and recently i am doing a web application on sending sms. anyone has got any codes for sending sms using vb.net?

or does anyone know where i can get relevant info for it.

Recommended Answers

All 36 Replies

yeah i also need someidea about that

hi, im new to vb.net and recently i am doing a web application on sending sms. anyone has got any codes for sending sms using vb.net?

or does anyone know where i can get relevant info for it.

Hi there
i have read ur question and u vl b surprised that instead of sending any solutions i m asking u the same question. i m also trying for the same thing as u r doing. what i have done is that i have developed a mail server and the person having registration in our mail server can mail each other. Now when any person is getting mail and if he is having a mobile then he will instantly get reported abt the mail. So plz do help me if u have find any code.
My email id is tailor_alpa@yahoo.com
Hoping and waiting for ur reply
Alpa tailor

hi both, i am now doing a project of sending sms using vb.net, but i have no idea of how to start, and do both of u have any code of that. and what type of gateway are you both using? thanks a millions. It is urgent. and my contact is april_er@msn.com. pls contact me thanks

Hi surprisely, so many people is lookign for the codes to sending sms in vb...Im also looking hard for it..=( I need the codes in vb.net...Any kind soul can help out us?? thanks alot man!!

Cheers...Happy chinese year in advance....

may i know what type of sms gateway u are using?

Hai guys ..Topic sounds interesting .....I wanna try that to......Can anybody give an explanation on how to achieve that...

In VB? you gotta be kidding!

To send SMS to mobile phone you cannot simply do it with "your own Code",
because SMS it's a resource inside the mobile network and the only way to
access it is by the means provided by the mobile operators (the network
owners).
most of them provide access trough web services, because it's a clean and
standard way that works throughout all platforms.
If you want "some other way" you can talk directly to the mobile operators
and ask them to provide you with SMPP access to the server, so you can send
messages from you code using SMPP instead of web services.

As posted by Letscode, you will have to use the SMPP server of the celular service provider. Depending on the country and the provider, it may be from easy to imposible to have them give you access to it. They may require a VPN connection to the computer making it happen. If you are going to use SMPP, you will need WinSock to create the connection and you will have to visit http://www.smsforum.net to learn SMPP. There yet is another way to do it. Read my next reply.

The other way, is by using a GSM modem. Brands are WaveCom Fastrack, Multitech and SonyEricson. The latest, called GM28 and distributed by www.toppcompanies.com is the one I found most reliable (I´ve tested the others).
If you go for a modem, you will have to use MSCOMM to communicate with the modem via Serial Port. The connection parameters will vary with each model. Then you will have to transmit AT commands to the modems to have them send and receive SMS.
To help you decide which method to use, read the next reply...

The SMPP option gives you these advantages and disadvantages:
- Massive amounts of SMS. Perfect for SMS spammers.
- Lower costs, depending whether your provider charges you for SMPP and how much.
- Providers rarely release access to SMPP to individuals. Sometimes not even companies.
The GSM Modem option gives you these other advantages:
- Freedom from the provider. Just insert the SIM and you are ready.
- It will handle (outgoing or incoming) only 1 message every 4.5 seconds.

Sample code... sorry is too much. But will gladly gide you to the pieces of the puzzle.

Oh.. and before I forget, there is also the posibility of ONLY Sending messages, by using PHP via HTTP. I know there is a way create your own internet explorer with vb, which I have not done yet. Therefore, all you need is to send the appropiate code to the URL provided by the carrier. For this, you will need to find out if your carrier allows SMS via HTTP, and if they will give you access to it. I have the PHP protocol needed for this somewhere. I´ll post it here later.

Well i can say i have done smething of this kind in VB before.U better go thru Hayes Commands which are used for sending and recieving SMS.

hye guys
Thers an easy way to send sms from ur .NET application
all u need is a web service that provides this,
well most of them are not for free, although u can use trial licences that let u send around 5 - 10 sms's for free
u can try out Stike Iron ( 10 sms free for trial licence)

http://ws.strikeiron.com/SMSTextMessaging?WSDL

just add the web reference to this wsdl from ur VS and thats as easy as it gets

Happy sms 'ing

PS: i have a sample application if anyone wants mail me:dharshan.ks@gmail.com

Cheers

Below is simple code:

Imports System.Web.Mail
.
.
.
Dim toPhoneNumber As String = "DestinationPhoneNumber";
Dim login As String = "YouredomainUsername"
Dim password As String = "YourPassword"
Dim compression As String = "Compression Option goes here "
Dim body As String = "Your Message"
Dim mail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage

mail.To = toPhoneNumber + "@sms.domainname.com"
mail.From = login + "@domain.com"
mail.Subject = compression
mail.Body = body
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", login)
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password)


System.Web.Mail.SmtpMail.SmtpServer = "domain.com";
System.Web.Mail.SmtpMail.Send(mail)

or u can find out on this link below:
http://www.ipipi.com/help/send_text_message_using_vb_net.htm

There is one way to send for free without using an sms gateway but you have to know the carrier the person is on. You can then send an email. Most are in the form of mobilenumber@carrierssmsemail.tld For example verizon is mobilenumber@vtext.com and most major carriers have similar.

HI,
Here is code for a dll file for VB.NET 2005 that I am currently using to send SMS Messages. Receiving SMS Messages are not done yet, but I will post it when it is done. This Code will work with FARGO Maestro 100 GSM Modem (WAVECOM)

Please note that this code use threading ...

Option Explicit On
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.IO.Ports
 
 
 
PublicClass SMSCOMMS
Private WithEvents SMSPort As SerialPort
Private SMSThread As Thread
Private ReadThread As Thread
Shared _Continue As Boolean = False
Shared _ContSMS As Boolean = False
Private _Wait As Boolean = False
Shared _ReadPort As Boolean = False
Private WithEvents DBServer As Postgres
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)
 
Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
With SMSPort
.PortName = COMMPORT
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
DBServer = New Postgres()
ReadThread = New Thread(AddressOf ReadPort)
End Sub
 
Public Function SendSMS(ByVal CellNumber As String, ByVal SMSMessage As String) As Boolean
Dim MyMessage As String = Nothing
'
'Check if Message Length <= 160
If SMSMessage.Length <= 160 Then
MyMessage = SMSMessage
Else
MyMessage = Mid(SMSMessage, 1, 160)
End If
'MsgBox("Sending " & MyMessage & " to " & CellNumber)
If IsOpen = True Then
SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCr)
_ContSMS = False
While _ContSMS = False
Application.DoEvents()
End While
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
_Continue = False
RaiseEvent Sending(False)
End If
End Function
 
 
Private Sub ReadPort()
Dim SerialIn As String = Nothing
Dim RXBuffer(SMSPort.ReadBufferSize) As Byte
Dim SMSMessage As String = Nothing
Dim Strpos As Integer = 0
Dim TmpStr As String = Nothing
While SMSPort.IsOpen = True
If (SMSPort.BytesToRead <> 0) And (SMSPort.IsOpen = True) Then
While SMSPort.BytesToRead <> 0
SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize) 'SMSPort.BytesToRead
SerialIn = SerialIn & System.Text.Encoding.ASCII.GetString(RXBuffer)
' Handle Internal Events
' For Received Characters
If SerialIn.Contains(">") = True Then
_ContSMS = True
End If
If SerialIn.Contains("+CMGS:") = True Then
_Continue = True
RaiseEvent Sending(True)
_Wait = False
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
 
End While
RaiseEvent DataReceived(SerialIn)
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
End While
End Sub
 
 
Public ReadOnly Property IsOpen() As Boolean
Get
If SMSPort.IsOpen = True Then
IsOpen = True
Else
IsOpen = False
End If
End Get
End Property
 
Public Sub Open()
If IsOpen = False Then
SMSPort.Open()
ReadThread.Start()
End If
End Sub
 
Public Sub Close()
If IsOpen = True Then
SMSPort.Close()
End If
End Sub
 
 
 
 
EndClass

Usage Of The Above Code Should be straight Forward, But Here Goes

In a Windows Form App

Option Explicit On
 
'Other Imports
Imports SMSCOMMS
' Rest of stuff
 
'Declarations
Public WitheEvents SMSEngine as SMSCOMMS
 
Public Sub Main()
   SMSEngine = New SMSCOMMS("COM1")
    SMSEngine.Open()
    SMSEngine.SendSMS("000000000","THIS IS YOUR MESSAGE")
End Sub
 
Public Sub Form_Close()
 SMSEngine.Close()
End Sub

I Hope this helps :)

I found a link to a page showing how to send text messages in .NET. Its in C# instead of VB.NET, but it should still help. Plus, the web service being used, webservicex, is a free unlimited service, so that should definitely be worth taking a look at if you need a free SMS web service.

Here's the link:

http://www.codeproject.com/cs/webservices/SendSmsThroughWS.asp

Hope this helps!

Jeff

hi, im new to vb.net and recently i am doing a web application on sending sms. anyone has got any codes for sending sms using vb.net?

or does anyone know where i can get relevant info for it.

I'm currently in the process of developing an VB.NET application that uses SMS. The absolute easiest way of doing this is to use an SMS gateway service such as ClickaTell to handle the actual bidirectional delivery. Using a gateway will allow you to deliver and recieve messages to/from many mobile networks and will greatly simplify your application development.

Hope this helps...

Anthony Papillion
Mobile Text Solutions
www.mobiletextsolutions.com

Yes you can send SMS from many mobile phones using your PC. But not all mobiles support that. You will have to check by connecting the mobile to your PC using its data cable and trying the command AT on it using hyper terminal.

There are many AT commands.

To send SMS you can can use

AT+CMGS=<number>
<message>ctrl+z

To read sms from inbox you can use

AT+CMGR=<address>
address is the location number, can be 1, 2... etc.

There are commands for almost everything you can do with the phone.

Before attempting this make sure that you are skillled in serial port programming.

Hello guyz...i need your advices for which method to use for sending SMS using .NET.
DO I USE THE SMPP (to access to the sever)?
or I USE THE WEB SERVICE PROVIDERS???
Thanks...
and for all the folks who want a piece of code...
Here's what ive done so far (i also need your feedbacks):

private void Send_Click(object sender, System.EventArgs e)
{
   try
      {
   	SmsTest.com.webservicex.www.SendSMSWorld smsWorld =  
         new SmsTest.com.webservicex.www.SendSMSWorld();
            smsWorld.sendSMS(txtEmailId.Text.Trim(), 
                    txtCountryCode.Text.Trim(), 
                    txtMobileNo.Text.Trim(), txtMessage.Text);
        lblMessage.Visible = true;
        lblMessage.Text="Message Send Succesfully";
      }
   
    catch(Exception ex)
    {
        lblMessage.Visible = true;
        lblMessage.Text="Error in Sending message"+ex.ToString();
    }
}

THANKS. assaf.rawad@gmail.com

I'm using VB6.O for such an application.all u need is to know modem (phone) AT commands ,API's and a connection to your comp using either IrDA (infrared ) or a RS232 cable for the same.

hi there
for sending sms to mobiles first of all you must select a protocol like SMTP/SMPP/HTTP. and for more details log on to www.planetsourcecode.com
yor techie

Hi,

Im from philippines and i have a fargo maestro 100.
I want to maximize its usage but i dont actually how.
can you teach me?

Anyways thanks for posting, this really a big help.

Thanks.

ajektus
Philippines

HI,
Here is code for a dll file for VB.NET 2005 that I am currently using to send SMS Messages. Receiving SMS Messages are not done yet, but I will post it when it is done. This Code will work with FARGO Maestro 100 GSM Modem (WAVECOM)

Please note that this code use threading ...

Option Explicit On
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.IO.Ports
 
 
 
PublicClass SMSCOMMS
Private WithEvents SMSPort As SerialPort
Private SMSThread As Thread
Private ReadThread As Thread
Shared _Continue As Boolean = False
Shared _ContSMS As Boolean = False
Private _Wait As Boolean = False
Shared _ReadPort As Boolean = False
Private WithEvents DBServer As Postgres
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)
 
Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
With SMSPort
.PortName = COMMPORT
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
DBServer = New Postgres()
ReadThread = New Thread(AddressOf ReadPort)
End Sub
 
Public Function SendSMS(ByVal CellNumber As String, ByVal SMSMessage As String) As Boolean
Dim MyMessage As String = Nothing
'
'Check if Message Length <= 160
If SMSMessage.Length <= 160 Then
MyMessage = SMSMessage
Else
MyMessage = Mid(SMSMessage, 1, 160)
End If
'MsgBox("Sending " & MyMessage & " to " & CellNumber)
If IsOpen = True Then
SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCr)
_ContSMS = False
While _ContSMS = False
Application.DoEvents()
End While
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
_Continue = False
RaiseEvent Sending(False)
End If
End Function
 
 
Private Sub ReadPort()
Dim SerialIn As String = Nothing
Dim RXBuffer(SMSPort.ReadBufferSize) As Byte
Dim SMSMessage As String = Nothing
Dim Strpos As Integer = 0
Dim TmpStr As String = Nothing
While SMSPort.IsOpen = True
If (SMSPort.BytesToRead <> 0) And (SMSPort.IsOpen = True) Then
While SMSPort.BytesToRead <> 0
SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize) 'SMSPort.BytesToRead
SerialIn = SerialIn & System.Text.Encoding.ASCII.GetString(RXBuffer)
' Handle Internal Events
' For Received Characters
If SerialIn.Contains(">") = True Then
_ContSMS = True
End If
If SerialIn.Contains("+CMGS:") = True Then
_Continue = True
RaiseEvent Sending(True)
_Wait = False
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
 
End While
RaiseEvent DataReceived(SerialIn)
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
End While
End Sub
 
 
Public ReadOnly Property IsOpen() As Boolean
Get
If SMSPort.IsOpen = True Then
IsOpen = True
Else
IsOpen = False
End If
End Get
End Property
 
Public Sub Open()
If IsOpen = False Then
SMSPort.Open()
ReadThread.Start()
End If
End Sub
 
Public Sub Close()
If IsOpen = True Then
SMSPort.Close()
End If
End Sub
 
 
 
 
EndClass

Usage Of The Above Code Should be straight Forward, But Here Goes

In a Windows Form App

Option Explicit On
 
'Other Imports
Imports SMSCOMMS
' Rest of stuff
 
'Declarations
Public WitheEvents SMSEngine as SMSCOMMS
 
Public Sub Main()
   SMSEngine = New SMSCOMMS("COM1")
    SMSEngine.Open()
    SMSEngine.SendSMS("000000000","THIS IS YOUR MESSAGE")
End Sub
 
Public Sub Form_Close()
 SMSEngine.Close()
End Sub

I Hope this helps :)

hi, i Saw ur Code to Send Message Using AT Command .Can u Pls Help me?
i m Working on Vb.net.
i want to Store Message in Variable When Any New Message Arrive On Hyperterminal.
and
How Can i Run Multiple AT commands together in vb.net?

pls friend help me.
if u Have and Code in vb.net to Recieve Message from port then Pls send me .........
thanx in Advance

HI,
Here is code for a dll file for VB.NET 2005 that I am currently using to send SMS Messages. Receiving SMS Messages are not done yet, but I will post it when it is done. This Code will work with FARGO Maestro 100 GSM Modem (WAVECOM)

Please note that this code use threading ...

Option Explicit On
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.IO.Ports
 
 
 
PublicClass SMSCOMMS
Private WithEvents SMSPort As SerialPort
Private SMSThread As Thread
Private ReadThread As Thread
Shared _Continue As Boolean = False
Shared _ContSMS As Boolean = False
Private _Wait As Boolean = False
Shared _ReadPort As Boolean = False
Private WithEvents DBServer As Postgres
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)
 
Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
With SMSPort
.PortName = COMMPORT
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
DBServer = New Postgres()
ReadThread = New Thread(AddressOf ReadPort)
End Sub
 
Public Function SendSMS(ByVal CellNumber As String, ByVal SMSMessage As String) As Boolean
Dim MyMessage As String = Nothing
'
'Check if Message Length <= 160
If SMSMessage.Length <= 160 Then
MyMessage = SMSMessage
Else
MyMessage = Mid(SMSMessage, 1, 160)
End If
'MsgBox("Sending " & MyMessage & " to " & CellNumber)
If IsOpen = True Then
SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCr)
_ContSMS = False
While _ContSMS = False
Application.DoEvents()
End While
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
_Continue = False
RaiseEvent Sending(False)
End If
End Function
 
 
Private Sub ReadPort()
Dim SerialIn As String = Nothing
Dim RXBuffer(SMSPort.ReadBufferSize) As Byte
Dim SMSMessage As String = Nothing
Dim Strpos As Integer = 0
Dim TmpStr As String = Nothing
While SMSPort.IsOpen = True
If (SMSPort.BytesToRead <> 0) And (SMSPort.IsOpen = True) Then
While SMSPort.BytesToRead <> 0
SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize) 'SMSPort.BytesToRead
SerialIn = SerialIn & System.Text.Encoding.ASCII.GetString(RXBuffer)
' Handle Internal Events
' For Received Characters
If SerialIn.Contains(">") = True Then
_ContSMS = True
End If
If SerialIn.Contains("+CMGS:") = True Then
_Continue = True
RaiseEvent Sending(True)
_Wait = False
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
 
End While
RaiseEvent DataReceived(SerialIn)
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
End While
End Sub
 
 
Public ReadOnly Property IsOpen() As Boolean
Get
If SMSPort.IsOpen = True Then
IsOpen = True
Else
IsOpen = False
End If
End Get
End Property
 
Public Sub Open()
If IsOpen = False Then
SMSPort.Open()
ReadThread.Start()
End If
End Sub
 
Public Sub Close()
If IsOpen = True Then
SMSPort.Close()
End If
End Sub
 
 
 
 
EndClass

Usage Of The Above Code Should be straight Forward, But Here Goes

In a Windows Form App

Option Explicit On
 
'Other Imports
Imports SMSCOMMS
' Rest of stuff
 
'Declarations
Public WitheEvents SMSEngine as SMSCOMMS
 
Public Sub Main()
   SMSEngine = New SMSCOMMS("COM1")
    SMSEngine.Open()
    SMSEngine.SendSMS("000000000","THIS IS YOUR MESSAGE")
End Sub
 
Public Sub Form_Close()
 SMSEngine.Close()
End Sub

I Hope this helps :)

Hi,

There is some sample code for sending an SMS via VB.NET, if you go to SNIP, click "Custom Development", then "developers", it shows you how

Dan.

sending sms using vb.net can be done by using Nokia dll file or sony erricson dll file. al hand set companies provide this dll file which can b included in the .net project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.