Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to send SMS using C#.net from connected mobile to PC to another mobile. How can I do?
Posted

Hello Shrikant,

Please have a look at this[^] sample. One more sample can be found on Nokia Developer Wiki[^].

regards,
Prasad P. Khandekar
 
Share this answer
 
Use This Code

C#
using System;
using System.Collections.Generic;
using System.Threading;
using System.IO.Ports;
using System.Windows.Forms;
using System.Management;
using System.Management.Instrumentation;

namespace gi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SerialPort s;
        private void button1_Click(object sender, EventArgs e)
        {

            string comport = cboPorts.Text;
            GetPort(comport);
        }
        public void GetPort(string comport)
        {
           // if (this.s == null)
            {
                this.s = new SerialPort();
                this.s.PortName = comport;
                this.s.Open();
                this.s.BaudRate = 9600;
                this.s.Parity = Parity.None;
                this.s.DataBits = 8;
                this.s.StopBits = StopBits.One;
                //this.s.Handshake = Handshake.RequestToSend;
                this.s.DtrEnable = true;
                this.s.RtsEnable = true;
                //this.s.RtsEnable = true;
                this.s.NewLine = System.Environment.NewLine;
                this.s.WriteLine("AT" + (char)(13));
                //string tt = s.ReadLine();
                if(s.ReadLine()!="AT/r/r")
                {
                    Thread.Sleep(2000);
                    this.s.WriteLine("AT+CMGF=1" + (char)(13));
                    Thread.Sleep(3000);
                    this.s.WriteLine("AT+CMGS=\"" + 8050398620 + "\"");
                    Thread.Sleep(5000);
                    this.s.WriteLine(">" + "le" + (char)(26));
                    this.s.Close();
                }
                else
                {
                    MessageBox.Show("Dervice Nt");
                }
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string[] ports = SerialPort.GetPortNames();


            foreach (string port in ports)
            {
                cboPorts.Items.Add(port);
            }
        }
    }
}
 
Share this answer
 
Comments
Shrikant Bhongade 23-Nov-13 0:53am    
I am using dongl for sending SMS
murkalkiran 23-Nov-13 2:48am    
ya i am worked using Dongle its working
agent_kruger 23-Nov-13 5:54am    
this code will work with dongle but is there another way to send SMS to other mobile by pushing command to the connected mobile to pc to send SMS?
Shrikant Bhongade 2-Dec-13 1:35am    
thanks to all i got it...

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