Contact Us

Send a text message with c# in under 2 minutes


Visual Studio 2019 or a later version with the .NET Core cross-platform development workload installed. For more information, see the Install with Visual Studio section on the Install the .NET Core SDK article from Microsoft.

Step 1: Set up a project

Open visual studio and start a new project. Select the template for "Console Application". Select > NET Core 3.0 and name your project. We’ll call this one “TestConsoleApp”.

Step 2: Install the SDK

The easiest way to import jc# dependencies is via NuGet which is built into the Visual Studio IDE. In the project menu in the toolbar, select “Manage Nuget Packages”. Search for the MessageMedia.SDK.Messages namespace and install the current version (2.0.0 at the time of this manual). Select the SDK and add it to your project.

Step 3: Add the code

Now the IDE will open up a Program.cs file automatically for you. Write the following in the code, subbing in your API key, secret and phone number:

using System;
using System.Collections.Generic;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Exceptions;
using MessageMedia.Messages.Models;

namespace TestConsoleApp
    class Program
        static void Main(string[] args)
            String API_KEY = "your api key";
            String API_SECRET = "your api secret";
            Boolean HMAC = false;
            MessageMediaMessagesClient client = new MessageMediaMessagesClient(API_KEY, API_SECRET, HMAC);

            MessagesController messages = client.Messages;

            SendMessagesRequest body = new SendMessagesRequest();
            body.Messages = new List();

            Message body_messages_0 = new Message();
            body_messages_0.Content = "Hello world!";
            body_messages_0.DestinationNumber = "+614";

                SendMessagesResponse result = messages.SendMessagesAsync(body).Result;
            catch (APIException e)
                Console.WriteLine(e.Message + e.ResponseCode + e.HttpContext.ToString());

Step 4: Send

Press the play button in Visual Studio. You should see a console (terminal or command line) pop up on your screen and it should send a message.  

You’ve now sent a simple message with C#. Check out the API documentation and the Github repository to see what else you can do.