Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone know please answer:


C# code for sending sms from pc to mobile via gateway or mail
Posted

 
Share this answer
 
C#
SMSAdapter adapter1 = new SMSAdapter();

adapter1.Username = "username";
adapter1.Password = "password";
SMSMessage message = new SMSMessage();
message.recipient = "mobileno";
message.message = txtmessage.Text;
adapter1.Send(message);
 
Share this answer
 
Comments
M.Narmatha 12-Apr-12 5:02am    
for wht username & password.
AshishChaudha 12-Apr-12 5:07am    
user name and password is provided from where you are taking the SMS services.
M.Narmatha 12-Apr-12 5:11am    
can i have mention that provider url..
Hi

Check this out for SMS API

By using that API we can send SMS which is recently I used

the Code in that API is detailed in API documentation

Here I'm providing sample code for that

The link to website is http://www.txtimpact.com/api.asp[^]
C#
string ret=string.Empty;
 WebRequest w=WebRequest.Create("http://smsapi.Wire2Air.com/smsadmin/submitsm.aspx");
 w.Method="POST";
 w.ContentType="application/x-www-form-urlencoded";
  using(Stream writeStream = w.GetRequestStream())
      {
       UTF8Encoding encoding = new UTF8Encoding();
       byte[] bytes = encoding.GetBytes("VERSION=2.0&userid=[username]&password=[userpassword]&VASId=[VASId] & PROFILEID =[ PROFILEID ]& FROM =27126&TO=[Mobile Number]&Text=[Text Message]);
     writeStream.Write(bytes, 0, bytes.Length);
      }
   using (HttpWebResponse r = (HttpWebResponse) w.GetResponse())
        {
       using (Stream responseStream = r.GetResponseStream())
          {
           using (StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8))
              {
              ret = readStream.ReadToEnd();
              }
          }
         }
    MessageBox.Show(ret); /* result of API call*/




All the Best
 
Share this answer
 
checkout this link. it is easy to learn and easy to understand
http://codehues.in/?p=34[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900