Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
DEAR ALL
please i need help in ASP.net
i try to send sms from AT Command and i successful in VB.net
but when i wirte and use same code in ASP.net so it is getting error just it goes else not read in if as i wrote code bellow you may see this
VB
Dim SerialPort1 As New SerialPort   ('i have to write this because in asp.net serial port not import)
        Try
            If SerialPort1.IsOpen Then
                With SerialPort1
                    .Write("AT" & vbCrLf)
                    .Write("AT+CMGF=1" & vbCrLf)
                    .Write("AT+CMGS=" & Chr(34) & TextBox1.Text & Chr(34) & vbCrLf)
                    .Write(TextBox2.Text & Chr(26))
                    MsgBox("sms Sent")

                End With
            Else
                MsgBox("ERROR MSG ON PORT")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

I tried this code and this is not works just it show msg this one
MsgBox("ERROR MSG ON PORT")

please i need help
Posted
Updated 19-Sep-13 8:12am
v3
Comments
Richard C Bishop 19-Sep-13 14:08pm    
ASP.Net is not a language. The code you have written is VB.Net, VB.Net is apart of ASP.Net.
[no name] 19-Sep-13 16:42pm    
Well obviously you are getting that error message because the port is not open.
irfanansari 20-Sep-13 14:28pm    
but i have open port when i connect it you may see this code
Try
With SerialPort1
.PortName = ComboBox1.Text
.BaudRate = 9600
.Parity = Parity.None
.StopBits = StopBits.One
.DataBits = 8
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
.Open()
MsgBox("Connected")


End With
Catch ex As Exception
MsgBox(ex.Message)

End Try
then i use this when try to send sms
Try
If SerialPort1.IsOpen Then
With SerialPort1
.Write("AT" & vbCrLf)
.Write("AT+CMGF=1" & vbCrLf)
.Write("AT+CMGS=" & Chr(34) & TextBox1.Text & Chr(34) & vbCrLf)
.Write(RichTextBox1.Text & Chr(26))
MsgBox("sms Sent")

End With
Else
MsgBox("ERROR MSG ON PORT")
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try

1 solution

By change, are you trying to use the serial port of another computer? See this page: Read serial port COMM1[^].
 
Share this answer
 
Comments
irfanansari 20-Sep-13 6:15am    
No Sir i Am using Serial Port My Own Computer as i Am using in vb.net and its works fine

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900