Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i need c# code for send sms to mobile phone.
Posted
Comments
Matej Hlatky 7-Mar-13 7:25am    
Just Google "Internet SMS Gateway" and choose one provider, which has .NET based API.

Why post the same thing in multiple forums? I replied you here: http://www.codeproject.com/Messages/4511897/Re-How-to-send-SMS-from-ASP-NET-application-to-mob.aspx[^]

Next time, please select one forum that you find best for your question and stick to it.
 
Share this answer
 
you can send sms web to mobile using serial port communication via gsm modem and code in given below.

C#
           sendsms sms = new sendsms(); // create object for class
            sms.mysms(txtmobnum.Text, TXTMSG.Text);


//send sms class

SerialPort SMSPort = new SerialPort(COM5, 9600, Parity.None, 8, StopBits.One);
    public void mysms(string mobile,string message)
    {
        string SerialIn = null;
        byte[] RXBuffer = new byte[SMSPort.ReadBufferSize + 1];

        if (!SMSPort.IsOpen)
        {
            SMSPort.Open();
            SMSPort.WriteLine("AT+CMGF=" + "1" + (char)(13));
            SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize);
            SerialIn = SerialIn + System.Text.Encoding.ASCII.GetString(RXBuffer);

            SMSPort.Write("AT+CMGS=" + "\"91" + mobile + "\"" + System.Environment.NewLine);
            SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize);
            SerialIn = SerialIn + System.Text.Encoding.ASCII.GetString(RXBuffer);

            SMSPort.Write(message+ (char)(26));
            SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize);
            SerialIn = SerialIn + System.Text.Encoding.ASCII.GetString(RXBuffer);
            SMSPort.Close();

        }
    }

[Edit]Code block added[/Edit]
 
Share this answer
 
v3

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