Search This Blog

Friday, December 9, 2011

Sending SMS Code in C#.Net

 
Please find below code for sending SMS
/// <summary>
        /// Sends SMS
        /// </summary>
        /// <returns> Returns true if SMS sent successfully </returns>

  private bool SendSMS()
        {
            try
            {
                if (string.IsNullOrEmpty(txtSMSPhoneNumber.Text.Trim()))
                {
                    MessageBox.Show("Please enter Phone Number to send SMS", "SMS Validation",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtSMSPhoneNumber.Focus();
                    return false;
                }
                if (txtSMSPhoneNumber.Text.Trim().Length < 10)
                {
                    MessageBox.Show("Invalid Phone Number. Please enter valid Phone Number", "SMS Validation",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtSMSPhoneNumber.Focus();
                    return false;
                }
                if (string.IsNullOrEmpty(txtSMSText.Text.Trim()))
                {
                    MessageBox.Show("Please text to SMS", "SMS Validation",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtSMSText.Focus();
                    return false;
                }

                string SMSText = txtSMSText.Text.Trim().Replace(" ", "");
                StringBuilder SMSURL = new StringBuilder();
                SMSURL.Append("http://smsoutbox.info/?user=Abm&password=abm567&PhoneNumber=91");
                SMSURL.Append(txtSMSPhoneNumber.Text.Trim());
                SMSURL.Append("&Text=");
                SMSURL.Append(SMSText);
                SMSURL.Append("&Sender=Minacs");

                //ProcessStartInfo PSInfo = new ProcessStartInfo("http://www.google.co.in/");
                //PSInfo.WindowStyle = ProcessWindowStyle.Minimized;
                //PSInfo.CreateNoWindow = true;
                //Process.Start(PSInfo);

                Process.Start(SMSURL.ToString());

                ShowWaiting("Sending SMS");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("Error in Function TestCustInfo.SendSMS. Error Message :- "
                    + ex.Message, ex);
            }
        }

12 comments:

  1. Hi there! This blog post could not be written any better!
    Going through this post reminds me of my previous roommate!

    He always kept preaching about this. I will forward this article to him.
    Pretty sure he's going to have a very good read. Thank you for sharing!

    Visit my web blog: clickbank review

    ReplyDelete
  2. Can you furnish additional information on this?

    Here is my homepage :: small business to start

    ReplyDelete
  3. I Preserve hearing towards the news speak just about acquiring free of charge on-line grant applications so I've been looking about for the optimal website to get one.

    my page ... resources

    ReplyDelete
  4. Hi, I usually do not recognize that, if the spot of their own RSS reader.
    Can you enable please:)

    Feel free to visit my blog post ... billigreisen türkei

    ReplyDelete
  5. Of course, as a vital internet site and informative posts I will give it back hyperlink - Bookmark this page?
    Regards

    Feel free to surf to my site - affiliate

    ReplyDelete
  6. Good post: P

    Here is my site urlaubsreise türkei

    ReplyDelete
  7. Asking questions are actually nice thing if you are not understanding something entirely,
    but this paragraph presents good understanding yet.

    Also visit my weblog ... tono ()

    ReplyDelete
  8. Nice post. I learn something totally new and challenging
    on blogs I stumbleupon everyday. It will always be useful to read content from other
    authors and use something from their web sites.

    Visit my page :: sunken

    ReplyDelete
  9. Thanks for sharing your thoughts about rasos.
    Regards

    Also visit my website - dcolumn

    ReplyDelete
  10. Hi! This is kind of off topic but I need some guidance from an established blog.
    Is it tough to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about making my own but I'm not sure where to start. Do you have any points or suggestions? Cheers

    Here is my web-site; watches ()

    ReplyDelete
  11. What's up to all, how is all, I think every one is getting more from this website, and your views are fastidious designed for new people.

    Here is my web site - laudeer

    ReplyDelete
  12. Could you please tell on which site we need to register for this? Is it free and available in India?

    ReplyDelete