Windows Forms: How to send SMS Messages to Mobile or Cell phone in C#

This post shows you how to send SMS to mobile or cell phone in C# Windows Forms Application

First off, You can open your Visual Studio, then create a new Windows Forms project called SmsMessages

c# sms message

Next, Open your form designer then drag Label, Button, TextBox controls into your form designer.

send sms clickatell

You can layout your form as the figure above.

Finally, Add a click event handler to the Send button that allows you to send sms messages in c#.

To send sms message in c#, you can create an account at the clickatell website. By default, when you sign up for an account you have 5 free SMS.

private void btnSend_Click(object sender, EventArgs e)
{
    try
    {
        WebClient client = new WebClient();
        //Call web api to send sms messages c#
        Stream s = client.OpenRead(string.Format("http://api.clickatell.com/http/sendmsg?user=YOUR USERNAME&password=YOUR PASSWORD&api_id=YOUR ID&to={0}&text={1}", txtTo.Text, txtMessage.Text));
        StreamReader reader = new StreamReader(s);
        string result = reader.ReadToEnd();
        MessageBox.Show(result, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

You can easily use the WebClient class to consume web api in c#

VIDEO TUTORIAL