Solved

How to send sms through C# application

Posted on 2013-02-04
7
2,227 Views
Last Modified: 2013-02-19
I have an application, that contains the Grid, which further contains the mobile no.s and Message.
On button click, i want the corresponding messages to be sms to every mobile no.

1. What are the things i need for this as the application is build in C#
2. Do i need the sms gateway server.
3. Is there free sms gateway server.
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 22

Assisted Solution

by:plusone3055
plusone3055 earned 200 total points
ID: 38850929
here is an article that explains in detail  w/code  :)

http://www.codeproject.com/Articles/19023/Sending-SMS-using-NET
0
 
LVL 22

Assisted Solution

by:plusone3055
plusone3055 earned 200 total points
ID: 38850940
0
 
LVL 10

Assisted Solution

by:Monica P
Monica P earned 200 total points
ID: 38853905
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:searchsanjaysharma
ID: 38854026
None is working
0
 
LVL 10

Assisted Solution

by:Monica P
Monica P earned 200 total points
ID: 38854146
0
 
LVL 9

Accepted Solution

by:
Orcbighter earned 100 total points
ID: 38864287
1. Just create a console application. See below
2. Do i need the SMS gateway server.
No. That will be provided by the company you subscribe to (see point 3)

3. There is no such thing as a free SMS service.
You have to choose a provider who will give you a gateway address. You can then use this to send your SMS texts to people.
These providers require a subscription (usually reasonable), which will allow you to send any number of SMS messages one at a time. If you want to be able to send texts to groups of numbers, that will probably cost more.

I wrote a program to send SMS messages to various mobile phones and found Clickatell to have a very easy to use API.
https://www.clickatell.com/
Check them out.

Clickatell is quite good. You get 10 free messages to test your code and then you can buy some subscriptions.
So, download their document describing their API and:

1. Create a simple console application.
2. Create a method called GetPhoneNumbers that returns a hard-coded list of mobile phone numbers). I used mine and my brothers (much to his annoyance).
3. Create a method called SendSMSText. Inside use a WebClient object and load up the properties of WebClient with your subscriber details, the desired phone number, and the text you want to send.

done.

Here is a simple test harness
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;


namespace SendSMS
{
    public class SendSMSApplication
    {
        string m_userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
        string m_baseURL = "http://api.clickatell.com/http/sendmsg";
        string m_username = "xxxxxxxxxxx";
        string m_password = "yyyyyyyy";
        string m_ap_id = "8888888";

        public SendSMSApplication()
        {
        }

        bool GetPhoneListForRule( int ruleID, ref List<string> phoneNumbers )
        {
            bool bRetStatus = true;

            phoneNumbers.Add( "22222222222" );
            phoneNumbers.Add( "33333333333" );

            return bRetStatus;
        }

        bool SendSMSText( List<string> phoneNumbers, string msgText )
        {
            bool bRetStatus = true;
            WebClient client = new WebClient();
            string multipleNumbers = String.Join( ",", phoneNumbers.ToArray() );

            client.Headers.Add( "user-agent", m_userAgent );
            client.QueryString.Add( "user", m_username );
            client.QueryString.Add( "password", m_password );
            client.QueryString.Add( "api_id", m_ap_id );

            //client.QueryString.Add( "to", "61412594784,61409595285" );
            client.QueryString.Add( "to", multipleNumbers );
            //client.QueryString.Add( "text", "This is an example message" );
            client.QueryString.Add( "text", msgText );

            using ( Stream data = client.OpenRead( m_baseURL ))
            {
                using ( StreamReader reader = new StreamReader( data ))
                {
                    string str = reader.ReadToEnd();
                    Console.WriteLine( str );
                }
            }

            return bRetStatus;
        }

        public void Run()
        {
            bool bAll_OK = true;
            List<string> phoneList = new List<string>();
            int ruleID = 24;

            bAll_OK = GetPhoneListForRule( ruleID, ref phoneList );

            if ( bAll_OK )
            {
                bAll_OK = SendSMSText( phoneList, "Hello World. This is a test message." );
            }
        }
    }
}

Open in new window

0
 

Author Closing Comment

by:searchsanjaysharma
ID: 38908274
tx
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using sqldatareader to populate cells in Excel-syntax 6 36
I need help adding validation to my MVC.Net view 6 37
Problem to copy file 14 92
Pdf not loading 2 41
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question