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

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

pashokpashok Posts: 2Member
hieeee

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
(manipulations)

example i have found a code in vb.net 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 vb.net


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
Try
com1Port = My.Computer.Ports.OpenSerialPort("COM1")
For i = 0 To i = 50
com1Port.WriteLine("1111111111111111") 'sending data
Next
com1Port.Write("serialData")
com1Port.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
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")
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))
MessageBox.Show(":send")
SMSPort.Close()
End If
End Function

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

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

Comments

Sign In or Register to comment.