Click here to Skip to main content
15,891,529 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
Posted
Comments
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.


C#
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()
        {
            InitializeComponent();
        }

        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)
     {
         try
         {
             MySqlConnection con = new MySqlConnection();
             // SqlCommand com = new SqlCommand( "select * from p_sms",con);
             con.ConnectionString = "server=localhost;Database=sms;uid=root;pwd=root";
             con.Open();
             MySqlDataReader myReader = null;
             MySqlCommand myCommand = new MySqlCommand("select * from p_sms", con);
             myReader = myCommand.ExecuteReader();
             _serialPort.Open();
             while (myReader.Read())
             {
                 Thread.Sleep(5000);
                 string ph;
                 ph = myReader[0].ToString();
                MessageBox.Show(ph);
                
                 _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("");
             
             }
             _serialPort.Close();

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

        private void button2_Click(object sender, EventArgs e)
        {
            //Form1.ActiveForm.Hide();
            new phone_no_table().Show();

        }
    }
}
 
Share this answer
 
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