Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a web form to send sms using a usb dongle. it worked properly at the first time and then it didn't work; But after several time it worked again. Whats wrong with this. I have attach my code follow.

What I have tried:

C#
int mSpeed = 1;
                serialPort.PortName = "COM6";
                serialPort.BaudRate = 9600;
                serialPort.Parity = Parity.None;
                serialPort.DataBits = 8;
                serialPort.StopBits = StopBits.One;
                serialPort.Handshake = Handshake.XOnXOff;
                serialPort.DtrEnable = true;
                serialPort.RtsEnable = true;
                serialPort.NewLine = Environment.NewLine;
                //serialPort.BreakState = true;
                serialPort.Open();

                serialPort.WriteLine("AT+CMGF=1" + Environment.NewLine);
                System.Threading.Thread.Sleep(200);
                serialPort.WriteLine("AT+CSCS=GSM" + Environment.NewLine);
                System.Threading.Thread.Sleep(200);
                serialPort.WriteLine("AT+CMGS=" + (char)34 + lblphone.Text + (char)34 + Environment.NewLine);    //Set Recievers Phone Number
                System.Threading.Thread.Sleep(200);
                serialPort.WriteLine(txtMessage.Text + (char)26);
                System.Threading.Thread.Sleep(mSpeed);
                serialPort.Close();
Posted
Updated 28-Oct-17 13:51pm
v2

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