title: SMS Sending Application in VB.net
body: <p>I'm trying to develop an application with vb.net 2008 to send sms to phone numbers from my pc. I've connected my nokia phone to my pc using USB cable (connected with COM3 port). Given bellow code which I have written should work but message is not being sent and I'm getting my app as deadlock condition:</p>
  
  <pre><code>Imports System
  Imports System.IO.Ports
  Imports System.Threading
  
  Public Class Form1
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Try
              Dim ports As String() = SerialPort.GetPortNames
  
              Dim port As String
  
              For Each port In ports
                  ComboBox1.Items.Add(port)
  
              Next port
  
          Catch ex As Exception
              MsgBox(ex.Message)
  
          End Try
      End Sub
  Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
          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 !", MsgBoxStyle.Information)
  
              End With
  
          Catch ex As Exception
              MsgBox(ex.Message)
  
          End Try
      End Sub
  Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
          Try
              If SerialPort1.IsOpen Then
                  With SerialPort1
                      .Write("AT" &amp; vbCrLf)
                      .Write("AT+CMGF=1" &amp; vbCrLf)
                      .Write("AT+CMGS=" &amp; Chr(34) &amp; TextBox1.Text &amp; Chr(34) &amp; vbCrLf)
                      .Write(RichTextBox1.Text &amp; Chr(26))
  
                      .Close()
                      MsgBox("Message Sent!", MsgBoxStyle.Information)
  
  
                  End With
  
              Else
                  MsgBox("Error on port")
              End If
          Catch ex As Exception
              MsgBox(ex.Message)
  
          End Try
      End Sub
  
  End Class
  </code></pre>