locked
how to send free SMS in windows Application Using C#

    Question

  • hello friends,

    i m bigner in windows Application using C#.. well do you have any idea how can i send SMS to any mobile network using C# windows Application .. what is the Code to write for that if you have any demo or any code then please let me its too urgent for me.... i will really appricate you...

    Thanks in Advance

    Naim Khan

    Monday, August 30, 2010 8:20 AM

All replies

  • First of all you need to find a way, where you are allowed to send free SMS. There is no direct connection between the internet and the phones, so you need to find someone who acts as gateway.

    And then you can use the given gateway. If you are lucky, the provider will give you a nice API (e.g. a Webservice) you could use. But normaly a SMS cost money (at least here in germany) so it can be hard to find such a provider. Some people offer free SMS on their webpage and they earn money through ads on the page. So it could be possible to simply send web requests to them (Which is not in their interest so they often make the user to read characters of a picture to a textbox so that a program like yours cannot misuse their service!)

    So if you want to know, how to use it, then you should first tell us, what service you want to use. Then we could help you in detail how to write such a solution.

    With kind regards,

    Konrad

    • Marked as answer by Naim Khan Monday, August 30, 2010 10:19 AM
    • Unmarked as answer by Naim Khan Monday, August 30, 2010 10:19 AM
    Monday, August 30, 2010 8:49 AM
  • thanks for the reply sir,

    which kind of Provider you are talking sir means i m new in this field so please tell me which kind of provide you want to know or if you have any kind of example related to this application or any demo then send me it will be help full for me...

    thanks in Advance

    Naim Khan

     

     

    Monday, August 30, 2010 10:19 AM
  • A provider is someone who provides you access to the mobile network. SOmething like these websites:
    http://freesms.smsix.net/
    http://www.sendsmsnow.com/

    (Results just came from google - I do not know them in any way!)

    But maybe you just have a closer look at this:
    http://www.codeproject.com/info/search.aspx?artkw=send+sms

    There are a lot of different articles about sending SMS on CodeProject. Maybe you find something usefull there.

    With kind regards,

    Konrad

    Monday, August 30, 2010 12:00 PM
  • hi khan,

                 Please check these useful links and read these article.

    How to Send SMS Messages from C# using an SQL Database:

    http://www.codeproject.com/KB/database/SMS_message_from_SQL.aspx

    check this link:

    http://bytes.com/topic/c-sharp/answers/256831-sending-sms-through-c

    http://www.soulcast.com/post/show/52339/SENDING-SMS-USING-C%23-source-code

    http://www.codeproject.com/KB/cpp/SendSmsThroughWS.aspx

    http://www.eggheadcafe.com/community/aspnet/2/10041741/sending-sms-through-net-c-windows-application.aspx

    Hope this is helpful and answer to your question.

     

     

     


    Thank You Tapan Pattanaik
    • Proposed as answer by TapanPattanaik Monday, August 30, 2010 12:17 PM
    Monday, August 30, 2010 12:17 PM
  • thanks for the reply but still i m not understand what should i make for this thing.. what is the first step...

    Please tell me step by step...

    Monday, August 30, 2010 6:57 PM
  • First of all you need  a sms gateway that allows Api methods and HTTP solution to pull sms through your website/application

    The gateway which i use is "smslane". In the c# code view, you need to add the following namespaces-

     

    using System.Text;

    using System.Net;

    using System.IO;

    using System.Collections.Specialized;

    //Then add the sample codes

     

    public partial class sms : System.Web.UI.Page

    {

        protected System.Web.UI.WebControls.Label lblSuccess;

        protected System.Web.UI.WebControls.Button btnSendSms;

        protected System.Web.UI.WebControls.TextBox txtContent;

        string a = "user=xyz"; //user name of your sms gateway

        string b = "&password=xyz"; //password of that sms gateway

        string c = "&msisdn="; //sender mobile number followed by country code

        string d = "&sid=WebSMS"; //predefined method from your gateways provider

        string e = "&msg="; //your message

        string f = "&fl=0"; //predefined value from your gateways provider

    //create a method

        private void SendSingleSms()

        {

            WebClient client = new WebClient();

            NameValueCollection sendNameValuCollection = new NameValueCollection();

            string uriString = "http://xyz.com/vendorsms/pushsms.aspx?" + a + b + c + d + e + + f;

            try

            {

                sendNameValuCollection.Add("login",login);

                sendNameValuCollection.Add("password", password);

                sendNameValuCollection.Add("type", type);

                sendNameValuCollection.Add("phoneno", phone);

                //sendNameValuCollection.Add("sendtime", time);

                sendNameValuCollection.Add("message", content);

                byte[] responseArrey = client.UploadValues(uriString, "POST", sendNameValuCollection);

                Label1.Text = Encoding.ASCII.GetString(responseArrey);

                sendNameValuCollection.Clear();

            }

            catch (WebException we)

            {

                lblSuccess = "Network Error: " + we.Message + "\nStatus Code: " + we.Status;

            }

            catch (UriFormatException ufe)

            {

                lblSuccess = "URI Format Error: " + ufe.Message;

            }

        }

        protected void SendButton_Click(object sender, EventArgs e)

        {

            SendSingleSms(); //the method you created above

        }

    }

    • Proposed as answer by Ricky.global9 Monday, December 26, 2011 6:06 AM
    Monday, December 26, 2011 5:56 AM
  • Hi Naim,

    Please find the below link

    http://www.c-sharpcorner.com/UploadFile/diya0076/827/

    it is described as web aspx pages you can convert it into a windows program.

     

    Regards

    Rajesh Kumar

    Wednesday, December 28, 2011 8:28 AM
  • Hi,

    The following piece of code will send SMS from your Windows Mobile

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.WindowsMobile.Telephony;
    using Microsoft.WindowsMobile.PocketOutlook;

    namespace SBSMProj
    {
        public partial class SendSMS : Form
        {
            public SendSMS()
            {
                InitializeComponent();
            }

            private void menuItem2_Click(object sender, EventArgs e)
            {
                MessageBox.Show(“Thanks for playing fair”);
                Application.Exit();
            }

            private void mnuMessage_Click(object sender, EventArgs e)
            {
                if (string.IsNullOrEmpty(mobileNumber.Text))
                {
                    MessageBox.Show(“Please Enter Mobile #”,”SB”);
                }
                else if (string.IsNullOrEmpty(smsMessage.Text))
                {
                    MessageBox.Show(“Please Enter Message”, “SB”);
                }
                else
                {
                    SmsMessage sms = new SmsMessage(mobileNumber.Text, smsMessage.Text);
                    sms.Send();
                    MessageBox.Show(“Message Sent Successfully to ” + mobileNumber.Text);

                    mobileNumber.Text = “”;
                    smsMessage.Text = “”;
                }
            }

        }
    }

     

    In short use the below code

    using Microsoft.WindowsMobile.Telephony;
    using Microsoft.WindowsMobile.PocketOutlook;

      SmsMessage sms = new SmsMessage(mobileNumber.Text, smsMessage.Text);
      sms.Send();

     

    I hope you got it !


    PS.Shakeer Hussain
    Wednesday, December 28, 2011 8:42 AM
  • Hear is the link

    http://reddyinfosoft.blogspot.in/2012/04/send-sms-using-way2sms-160by2-desktop.html

    for bulk sms

    http://reddyinfosoft.blogspot.in/2012/04/sen-bulk-sms-via-c-using-way2sms-160by2.html

    Monday, October 08, 2012 3:55 PM