I'm working on a messaging application
I have a gsm modem and device usb rs232
I want a private message to your phone from a form that I write
below is my code
but it don't work.
My phone does not receive any messages

namespace WindowsFormsApplication1
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            _serialPort = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
            //_serialPort.Open();
            _response = string.Empty;
            _serialPort.RtsEnable = true;
            _serialPort.DataReceived += SerialPortDataReceived;

        }
        private static SerialPort _serialPort;
        private string _response;
        void SerialPortDataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            if (e.EventType == SerialData.Chars)
            {
                _response += _serialPort.ReadLine();
            }
        }
        public bool IsReady()
        {
            try
            {
                if (!_serialPort.IsOpen)
                    _serialPort.Open();

                _serialPort.Write("AT\r");
                Thread.Sleep(3000);
            }
            catch
            {
                return false;
            }

            return _response.Contains("OK");
        }
        public static bool SendSms(string phoneNumber, string message)
        {
            try
            {
                if (!_serialPort.IsOpen)
                    _serialPort.Open();

                // Send
                _serialPort.Write("AT+CMGF=1\r");
                _serialPort.Write("AT+CMGS=\"" + phoneNumber + "\"\r\n");
                _serialPort.Write(message + "\x1A");
                return true;
            }
            catch
            {
                return false;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SendSms(textBox1 .Text , textBox2 .Text );
        }

    }
}

thanks a lot

Long ago we did stuff like that. Be sure your setup is good by opening the COM port with a terminal to test if the modem is working and what strings to send and expect.

These modems are all over the map so I had to dive into the modem's specifics back then. Today I'd repeat the same work such as a terminal for the first test and setting up other config items like we read at:
http://stackoverflow.com/questions/21522794/atcmgs-returns-error