Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am working on a c# windows form application, in that I have one form which is used to send the sms to the clients. To send sms I tried the below code but it is showing message failed. I don't know what to do. please correct me, help me.

What I have tried:

C#
if (txtMobile.Text == string.Empty)
           {
               MessageBox.Show("Enter Valid Mobile No");
           }
           else
           {
               using (System.Net.WebClient client = new System.Net.WebClient())
               {

                   try
                   {
                       string url = "http://bulksms.abc.in/API/WebSMS/Http/v1.0a/index.php? " +
                       "&username=" + System.Web.HttpUtility.UrlEncode(txtUserName.Text) +
                       "&password=" + System.Web.HttpUtility.UrlEncode(txtPassword.Text) +
                       "&sender=" + txtSenderID.Text +
                       "&to=" + txtMobile.Text +
                       "&message=" + System.Web.HttpUtility.UrlEncode(txtSmsContent.Text, System.Text.Encoding.GetEncoding("ISO-8859-1"));

                       string result = client.DownloadString(url);
                       if (result.Contains("OK"))
                           MessageBox.Show("Your message has been successfully sent.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       else
                           MessageBox.Show("Message Failed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   }
                   catch (Exception exr)
                   {
                       MessageBox.Show(exr.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   }
               }

           }
Posted
Updated 2-Feb-18 2:30am
Comments
Richard MacCutchan 2-Feb-18 3:41am    
What result did you receive from the server?
Member 11764921 2-Feb-18 4:30am    
@Richard MacCutchan, I am getting Message failed error
Richard MacCutchan 2-Feb-18 8:36am    
No, you are displaying "Message Failed". What error do you receiver from the server?

1 solution

Your code is sending something to a php file. You have to contact whoever built that file to get a better understanding of why it failed. There is no way for us to know.
 
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