Friday, February 17, 2012 7:36 PM
Please tell me what's the wrong in this code, I can't understand the problem when I want to send sms though my Desktop application in C#. It does not send sms using GSM MODEM.............................. Also Explain the problem in detail........
private void btnSendSms_Click(object sender, EventArgs e)
public void sendSMS()
if ( serialPort.IsOpen == true )
serialPort.PortName = "Com1";
serialPort.Parity = Parity.None;
serialPort.Handshake = Handshake.RequestToSend;
serialPort.BaudRate = 9600;
serialPort.DataBits = 8;
serialPort.DtrEnable = true;
serialPort.RtsEnable = true;
serialPort.StopBits = StopBits.One;
serialPort.WriteLine("AT" + (char)13);
serialPort.WriteLine("AT+CMGF=1" + (char)13);
serialPort.WriteLine("AT+CSCA=" + mtxtSMCSNo.Text + "" + (char)13);
serialPort.WriteLine("AT+CMGS=" + mTxtCellNo.Text + "" + (char)13 + ">");
serialPort.WriteLine(txtMessage.Text + (char)(26));
MessageBox.Show("Message sent successfully");
MessageBox.Show("Port Close Successfully");
Here I am using MaskedTextBox of Cell No and Center No..............
Saturday, February 18, 2012 3:16 AM
I think the most obvious one is that, the remote side is sending you return message but you never try to read, how would you expect the remote side set the RTS flag for you?
You can see working code from someone who asked for help on sending SMS here.
EDIT: I'll add that the protocol require your commands to end with '\r' only, so you shouldn't use WriteLine() unless you somehow found a way to set the Environment.NewLine to '\r'. (The property is read-only) Although I suspect the GSM modem will just ignore the '\n' afterwards...
- Edited by cheong00 Saturday, February 18, 2012 3:21 AM
Saturday, February 18, 2012 4:34 PM
Check below SMS Sample
- Edited by Olivia.Patterson Saturday, February 18, 2012 6:02 PM