Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm a beginer C#, and i don't know how to start coding for small winform app to send message to a cell phone.
This application may be not using free webservices, have to 3 textbox to users can input from(and) mobile number, text message and then have one button Send is ok.

Experts coder, pls tell me how to?
Posted

You can send sms from Winform Application to Mobile phone by modem.
you have to know which port the modem is connected.
using System.IO.Ports;

SerialPort srpModemPort = null;

            string port_name = "COM1";
            srpModemPort = new SerialPort();
            srpModemPort.PortName = port_name;
            srpModemPort.BaudRate = 115200;
            srpModemPort.Parity = Parity.None;
            srpModemPort.DataBits = 8;
            srpModemPort.StopBits = StopBits.One;
            srpModemPort.Handshake = Handshake.RequestToSend;
            srpModemPort.DtrEnable = true;
            srpModemPort.RtsEnable = true;
            srpModemPort.NewLine = System.Environment.NewLine;
            srpModemPort.WriteTimeout = 2000;

Then you can send sms by this ->

            string mobile_number = "+88XXXXXXXXXXX";
            string message = "Hi";
           
            try
            {
                if (!srpModemPort.IsOpen)
                    srpModemPort.Open();
                srpModemPort.WriteLine("AT+CMGS=" + mobile_number + "\r" + message + (char)(26));

                MessageBox.Show("Message Send.....");

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
 
Share this answer
 
v2
Comments
[no name] 29-Sep-10 19:22pm    
Format code snippets
ThaoXXX 30-Sep-10 5:25am    
Hi Shakil03040003,
i've try your code, message #Quote#Msg Send ...#Quote# was dispalyed, but my phone was not still received this msg??? Could you pls check for me?

--> My code is only modify port_name to #Quote#COM3#Quote#.

Thanks many.
shakil0304003 30-Sep-10 6:49am    
--> My code is only modify port_name to #Quote#COM3#Quote#.

you have to change the mobile_number.
Your port name may be wrong, to check it, go to the huper terminal menu in communications & try to connect with the modem. If which port you will connect modem to huper terminal, use that port name of this code, And before the code run, you have to disconnect huper terminal from the modem :D I hope it will help.
ThaoND,

--> My code is only modify port_name to #Quote#COM3#Quote#.

you have to change the mobile_number.
Your port name may be wrong, to check it, go to the huper terminal menu in communications & try to connect with the modem. In which port you will connect modem to huper terminal, use that port name of this code, And before the code run, you have to disconnect huper terminal from the modem :D I hope it will help.
 
Share this answer
 
Search in the Articles here on Code Project. There are several examples.

Otherwise use a search engine.
 
Share this answer
 
 
Share this answer
 
Thanks all for sharing, i'll applied the solution of shakil0304003 first. :-O

ThaoND.
 
Share this answer
 
Thanks many to shakil0304003 for your answer, i'll check it later. :)

ThaoND.
 
Share this answer
 

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