Send SMS and MMS Messages in Visual Basic.NET

In this guide, we'll show you how to use Programmable SMS to send SMS and MMS messages in your ASP.NET web application. The code snippets in this guide are written using modern VB.NET language features and require the .NET Framework version 4.5 or higher. They also make use of the Twilio .NET SDK.

Let's get started!

Outgoing SMS Diagram

Sign up for a Twilio Account

To use the Twilio REST API, you need an account. Signing up for a free Twilio account is easy. Once you've signed up, head over to your Console and grab your Account SID and your Auth Token. You will need those for the code samples below.

Purchase an SMS Capable Phone Number

Sending SMS messages requires an SMS capable phone number. You can browse the available phone numbers in the Console. Be sure that the phone number you buy is SMS capable. When you search, you can check the box to filter available numbers to those that are SMS capable:

Search for SMS Capable Number

When viewing the search results, you can see the capability icons in the list of available numbers:

Buy SMS Capable Number

Armed with a Twilio phone number, you can now start sending messages to mobile devices.

Send an SMS Message via the REST API with VB.NET

Sending an outgoing SMS message requires sending an HTTP POST to the Messages resource URI. Using the helper library, you can create a new instance of the Message resource and specify the To, From, and Body parameters for your message.

Loading Code Samples...
Language
' Download the Twilio .NET library from twilio.com/docs/libraries/csharp
Imports Twilio
Imports Twilio.Rest.Api.V2010.Account
Imports Twilio.Types

Module Module1

    Sub Main()
		' Find your Account Sid and Auth Token at twilio.com/console
		Const  accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
		Const  authToken = "your_auth_token"
		TwilioClient.Init(accountSid, authToken)

		Dim toNumber = New PhoneNumber("+15017250604")
		Dim message = MessageResource.Create(
            toNumber, from := New PhoneNumber("+15558675309"), 
            body := "This is the ship that made the Kessel Run in fourteen parsecs?")

		Console.WriteLine(message.Sid)
    End Sub

End Module
Send an SMS with Visual Basic.NET

If you want to send a message to several recipients, you could simply create an array of recipients and iterate through each phone number in that array. You can send as many messages as you like, as fast as you like and Twilio will queue them up for delivery at your prescribed rate limit. See our guide on how to Send Bulk SMS Messages for more tips.

Send a Message with Media (MMS)

It's also easy to send an outgoing MMS using Twilio. To send an MMS, you also make an HTTP POST request to the Messages resource but this time specify a parameter for the URL of media, such as an image.

MMS messages can only be sent and received by numbers having MMS capability. You can check the capabilities of numbers in the account portal or query the Available Phone Numbers resource to search for Twilio numbers that are MMS enabled.

Loading Code Samples...
Language
' Download the Twilio .NET library from twilio.com/docs/libraries/csharp
Imports Twilio
Imports Twilio.Rest.Api.V2010.Account
Imports Twilio.Types

Module Module1

    Sub Main()
		' Find your Account Sid and Auth Token at twilio.com/console
		Const  accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
		Const  authToken = "your_auth_token"
		TwilioClient.Init(accountSid, authToken)

		Dim mediaUrl = New List(Of Uri)() From { _
			New Uri("https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg") _
		}
		Dim toNumber = New PhoneNumber("+15017250604")
		Dim message = MessageResource.Create(
            toNumber, 
            from := New PhoneNumber("+15558675309"), 
            body := "This is the ship that made the Kessel Run in fourteen parsecs?", 
            mediaUrl := mediaUrl)

        Console.WriteLine(message.Sid)
    End Sub

End Module
Send a Message with an Image URL with Visual Basic.NET

For more information about sending SMS and MMS messages, see the REST API Reference.

David Prothero
Jarod Reyes
Andrew Baker
Ricky Robinett

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
' Download the Twilio .NET library from twilio.com/docs/libraries/csharp
Imports Twilio
Imports Twilio.Rest.Api.V2010.Account
Imports Twilio.Types

Module Module1

    Sub Main()
		' Find your Account Sid and Auth Token at twilio.com/console
		Const  accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
		Const  authToken = "your_auth_token"
		TwilioClient.Init(accountSid, authToken)

		Dim toNumber = New PhoneNumber("+15017250604")
		Dim message = MessageResource.Create(
            toNumber, from := New PhoneNumber("+15558675309"), 
            body := "This is the ship that made the Kessel Run in fourteen parsecs?")

		Console.WriteLine(message.Sid)
    End Sub

End Module
' Download the Twilio .NET library from twilio.com/docs/libraries/csharp
Imports Twilio
Imports Twilio.Rest.Api.V2010.Account
Imports Twilio.Types

Module Module1

    Sub Main()
		' Find your Account Sid and Auth Token at twilio.com/console
		Const  accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
		Const  authToken = "your_auth_token"
		TwilioClient.Init(accountSid, authToken)

		Dim mediaUrl = New List(Of Uri)() From { _
			New Uri("https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg") _
		}
		Dim toNumber = New PhoneNumber("+15017250604")
		Dim message = MessageResource.Create(
            toNumber, 
            from := New PhoneNumber("+15558675309"), 
            body := "This is the ship that made the Kessel Run in fourteen parsecs?", 
            mediaUrl := mediaUrl)

        Console.WriteLine(message.Sid)
    End Sub

End Module