////Sets the properties of serial port object
serialport.PortName = cboPort.SelectedItem.ToString();
serialport.BaudRate = 9600;
serialport.Parity = Parity.None;
serialport.DataBits = 8;
serialport.StopBits = StopBits.One;
serialport.Handshake = Handshake.RequestToSend;
serialport.DtrEnable = true;
serialport.RtsEnable = true;
//Open the port to send sms
serialport.Open();
serialport.WriteLine("AT+CMGF=0" + Environment.NewLine);
serialport.WriteLine("AT+CSCA=\"" + txtServiceNo.Text + ",145\"" + Environment.NewLine);
//Sets destination number
serialport.WriteLine("AT+CMGS=\"" + sms.DestinationNo + "\"" + Environment.NewLine);
//Specifies message and sends Ctrl+z
serialport.WriteLine(sms.Message + (char)26);
//Displays buffer containing output messages
System.Threading.Thread.Sleep(1500);
|