Click here to Skip to main content
15,615,583 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I m working in C# and I want to send Message to Mobile from My Application through my mobile Please Help me
ridoy 6-Sep-13 10:21am    
so make 2 applications, 1 for server and one for client and install it in 2 mobiles!
me.ajaykumar 7-Sep-13 7:05am    
you mean, you want to use a gsm connection to send mesage to some other cell phone?

1 solution

steps to achieve this->

1. connect a cell phone to you computer using a Serial port connection,
2. this is a code written in c#, using "AT" command set.

Rest, no one will spoon feed you.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MySql.Data.Types;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
namespace WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
     SerialPort _serialPort;
     StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
    _serialPort = new SerialPort();
     _serialPort.PortName = textBox2.Text;
     _serialPort.BaudRate = 2400;
     _serialPort.Parity = Parity.None;
     _serialPort.DataBits = 8;
     _serialPort.StopBits = StopBits.One;
     _serialPort.Handshake = Handshake.RequestToSend;
     string b;
     b = textBox1.Text;
     if (b.Length <= 158)
             MySqlConnection con = new MySqlConnection();
             // SqlCommand com = new SqlCommand( "select * from p_sms",con);
             con.ConnectionString = "server=localhost;Database=sms;uid=root;pwd=root";
             MySqlDataReader myReader = null;
             MySqlCommand myCommand = new MySqlCommand("select * from p_sms", con);
             myReader = myCommand.ExecuteReader();
             while (myReader.Read())
                 string ph;
                 ph = myReader[0].ToString();
                 _serialPort.Write("at" + (char)13 + (char)13);
                 _serialPort.Write("at+cmgf=1" + (char)13 + (char)13);
                 _serialPort.Write("at+cmgs=\"" + ph + "\"" + (char)13 +(char)13);

                 _serialPort.Write(b + (char)26 + (char)26 + (char)13);
                // _serialPort.Write("");

             textBox1.Text = "";
         catch (Exception ex)
             MessageBox.Show("chk out the hardware connected ");
         MessageBox.Show("text out of length.please enter a msg less then 160 characters");

        private void button2_Click(object sender, EventArgs e)
            new phone_no_table().Show();

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