C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Send SMS to a Mobile Phone Using C#


Posted Date: 23 Jun 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: Pradeep KintaliMember Level: Gold    
Rating: 1 out of 5Points: 10



This example shows how to send SMS to a mobile phone using C#.

public void SendSMS(stirng msg, string mobileno)
{
///SMS GATEWAY PROVIDER PATH
string url = "http://XXXXProvider.com?phoneNumber={0}&MsgTxt={1}";

string url1 = String.Fomat(url, mobileNo, msg);

//create Web Request object for the url
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url1);

// get the response from the web request
HttpWebResponse res = (HttpWebResponse)req.GetResponse();

// read the response from the WebResponse in to a stram
Stream s = res.GetResponseStream();
StreamReader rdr = new StreamReader(s);
string result = rdr.ReadLine();
s.Flush();
s.Close();
}



Responses

Author: Fool To Code    01 Dec 2008Member Level: Gold   Points : 2
for asp.net see this code:

Dim XMLHttp, DataToSend, PostUrl
DataToSend = ""
PostUrl = "http://www.your sms provider name.com"
DataToSend = DataToSend & "?sername=username"
DataToSend = DataToSend & "&pass=password"
DataToSend = DataToSend & "&senderid=senderid"
DataToSend = DataToSend & "&dest_mobileno=" & dgitem.Cells(2).Text & ""
DataToSend = DataToSend & "&message=" & txtMessage.Text & ""
PostUrl = PostUrl & DataToSend
XMLHttp = Server.CreateObject("MSXML2.XMLHttp")
XMLHttp.Open("GET", PostUrl, False)
XMLHttp.setRequestHeader("Content-Type", "application/x-www-form- urlencoded")
XMLHttp.send("")



Author: Fool To Code    01 Dec 2008Member Level: Gold   Points : 2
for desktop application:

Dim baseurl As String=write complete string as given by your provider
Dim data As Stream = client.OpenRead(baseurl)
Dim reader As StreamReader = New StreamReader(data)
Dim s As String = reader.ReadToEnd()
data.Close()
reader.Close()
'Return
MessageBox.Show("message sent")



Author: KR    12 Dec 2008Member Level: Gold   Points : 0
Hi,

Veery useful code..

Regards
Vijay


Author: Deepika Haridas    15 Dec 2008Member Level: Diamond   Points : 0
Good useful code..
Thanks for posting..

Regards,
Deepika


Author: Sayre    25 May 2009Member Level: Gold   Points : 0
Hi, thanks for posting.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Send sms in C#  .  Send SMS  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to access sealed class methods
Previous Resource: Reading Excel Sheet Names in C#
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use