Azure

Sending SMS Notifications with Azure Communication Providers in .NET

Introduction

On this article, we are going to ship SMS Notifications with Azure Communication Service utilizing .NET. That is an alternative choice to certainly one of my earlier articles, “Sending SMS Notifications with Azure Communication Service utilizing Python.” As an alternative of Python, let’s obtain this in .NET.

Step 1. Set up the Azure Communication Providers SDK.

Set up-Bundle Microsoft.Azure.Communication.Sms

Step 2. Import obligatory libraries.

utilizing Azure;
utilizing Azure.Communication;
utilizing Azure.Communication.Sms;
utilizing System;
utilizing System.Threading.Duties;

Step 3. Azure Communication Providers Connection String.

string connectionString = "<YOUR_CONNECTION_STRING>";

Substitute <YOUR_CONNECTION_STRING> with the precise connection string from the Azure Communication Providers useful resource.

Step 4. SmsClient.

var smsClient = new SmsClient(connectionString);

Step 4. Initialize the telephone quantity and message that you should ship.

var toPhoneNumber = "<TO_PHONE_NUMBER>";

var message = "Good day, this can be a take a look at message!";

Step 5. Sending SMS.

strive
{
    SendSmsOptions smsOptions = new SendSmsOptions(new PhoneNumber(toPhoneNumber), message);
    Response response = await smsClient.SendAsync(smsOptions);
    Console.WriteLine($"SMS despatched efficiently. Message Id: {response.Worth}");
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"Didn't ship SMS. Error: {ex.Message}");
}

By following these steps, we will provoke SMS notifications utilizing .NET.

Know extra about our firm at Skrots. Know extra about our companies at Skrots Providers, Additionally checkout all different blogs at Weblog at Skrots

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button