java code to send sms from pc to mobile without using gsm modem


I need a code in java that will send an sms from a pc to a user's mobile phone... Instead of using a gsm modem connected to a pc, to do the above, i want to connect a mobile phone to the pc that will act as a gsm modem...The code should be such that once i say run it sends the sms directly to user's mobile without requiring any other manipulations to be done on--> the mobile which is connected to pc....or anywhere else

example i have found a code in that does the similar thing but i want an equivalent code in java for the following code cause i am using java for my project ...its very urgent ....can i please get help?

code in

Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add the COM POrt on Which ur connected here... else it works fine ya
Dim SMSEngine As New SMSCOMMS("COM7")
Dim i As Integer
SMSEngine.Open() 'open the port
SMSEngine.SendSMS() 'send the SMS
'send a signal on serial port so that buzzer rings
Dim com1Port As IO.Ports.SerialPort = Nothing
com1Port = My.Computer.Ports.OpenSerialPort("COM1")
For i = 0 To i = 50
com1Port.WriteLine("1111111111111111") 'sending data
Catch ex As Exception
If (com1Port IsNot Nothing) Then com1Port.Dispose()
com1Port = Nothing
End Try
End Sub
End Class

Public Class 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
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 = 19200
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
End Sub
Public Function SendSMS() As Boolean
If SMSPort.IsOpen = True Then
'sending AT commands
SMSPort.WriteLine("AT+CMGF=1" & vbCrLf)
SMSPort.WriteLine("AT+CSCA="" +919823000040""" & vbCrLf)
SMSPort.WriteLine("AT+CMGS=""+919960920107""" & vbCrLf)
_ContSMS = False
SMSPort.WriteLine("test message!!" & vbCrLf & Chr(26))
End If
End Function

Public Sub Open()
If Not (SMSPort.IsOpen = True) Then
End If
End Sub

Public Sub Close()
If SMSPort.IsOpen = True Then
End If
End Sub
End Class


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!