TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Message Send In C#
Gokul
Jun 23
2016
Code
1.2
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
string
authKey = authkey;
//Multiple mobiles numbers separated by comma
string
mobileNumber = txtphno.Text;
//Sender ID,While using route4 sender id should be 6 characters long.
string
senderId = username1;
//Your message to send, Add URL encoding here.
string
msg = HttpUtility.UrlEncode(txtmessage.Text);
//Prepare you post parameters
StringBuilder sbPostData =
new
StringBuilder();
sbPostData.AppendFormat(
"authkey={0}"
, authKey);
sbPostData.AppendFormat(
"&mobiles={0}"
, mobileNumber);
sbPostData.AppendFormat(
"&message={0}"
, msg);
sbPostData.AppendFormat(
"&sender={0}"
, senderId);
sbPostData.AppendFormat(
"&route={0}"
,
"4"
);
try
{
//Call Send SMS API
string
sendSMSUri =
"Your key"
;
//Create HTTPWebrequest
HttpWebRequest httpWReq = (HttpWebRequest) WebRequest.Create(sendSMSUri);
//Prepare and Add URL Encoded data
UTF8Encoding encoding =
new
UTF8Encoding();
byte
[] data = encoding.GetBytes(sbPostData.ToString());
//Specify post method
httpWReq.Method =
"POST"
;
httpWReq.ContentType =
"application/x-www-form-urlencoded"
;
httpWReq.ContentLength = data.Length;
using
(Stream stream = httpWReq.GetRequestStream()) {
stream.Write(data, 0, data.Length);
}
//Get the response
HttpWebResponse response = (HttpWebResponse) httpWReq.GetResponse();
StreamReader reader =
new
StreamReader(response.GetResponseStream());
string
responseString = reader.ReadToEnd();
//Close the response
reader.Close();
response.Close();
MessageBox.Show(
"Your Message has been Sent."
,
"Message"
.net windows application
C#