Windows Forms: Send SMS Message in C#

How to Send SMS Messages to Mobile or Cell phone via the internet using vianett api in C#

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "SendSmsMessage" and then click OK

send sms messages

Step 2: Design your form as below

send sms message using vianett

Step 3: Add code to handle btnSend click event

private void btnSend_Click(object sender, EventArgs e)
    using (System.Net.WebClient client = new System.Net.WebClient())
            string url = "" +
                "src=" + txtPhoneNumber.Text + "&" +
                "dst=" + txtPhoneNumber.Text + "&" +
                "msg=" + System.Web.HttpUtility.UrlEncode(txtMessage.Text, System.Text.Encoding.GetEncoding("ISO-8859-1")) + "&" +
                "username=" + System.Web.HttpUtility.UrlEncode(txtUsername.Text) + "&" +
                "password=" + System.Web.HttpUtility.UrlEncode(txtPassword.Text);
            //Call web api to send sms messages
            string result = client.DownloadString(url);
            if (result.Contains("OK"))
                MessageBox.Show("Your message has been successfully sent.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show("Message send failure.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        catch (Exception ex)
            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

To play demo you need to create an account at vianett website. ViaNett is working hard to ensure that any developer who wants to use our messaging gateway in their application, site or system, can do so reliably and simply