C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Send SMS to a Mobile Phone Using C#


Posted Date: 23 Jun 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: Pradeep Kintali       Member Level: Gold
Rating:     Points: 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: Deepak    01 Dec 2008Member Level: Silver   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: Deepak    01 Dec 2008Member Level: Silver   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")



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
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!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use