C# code example

ViaNett provides you with code examples and programming objects, to help you connect to our gateway using the programming language of your choice. You are welcome to try these scripts. Sign up now to get 5 free SMS.

What is C#?

C# is an object-oriented programming language which is implemented on the Microsoft .NET Framework. Microsoft supplies a powerful version free of charge.

C# example code

This example code uses a ready-made object, based on the HTTP API. To use this script, simply register for free and get 5 free SMS.

        string username = "username";

        string password = "password";
        string msgsender = "4790000000";
        string destinationaddr = "4790000000";
        string message = "hello world";
        
        ViaNettSMS s = new ViaNettSMS(username, password);
        ViaNettSMS.Result result;
        try
        {
            result = s.sendSMS(msgsender, destinationaddr, message);
            if (result.Success)
            {
                Debug.WriteLine("Message successfully sent");
            }
            else
            {
                Debug.WriteLine("Received error: " + result.ErrorCode + " " + result.ErrorMessage);
            }
        }
        catch (System.Net.WebException ex)
        {
            //Error occurred while connecting to server.
            Debug.WriteLine(ex.Message);
        }
 

"ViaNettSMS" C# object

ViaNett provides you with an object/class in C#, based on the HTTP API. The source code is available for download.

Download source code

You need to log in to download the source code. Sign up now and get 5 free SMS messages.

Click here to download the source code.