This topic provides a comprehensive guide on how to utilize Alibaba Cloud SMS SDK for .NET. By incorporating this SDK as a dependency in your application, you can easily integrate the SendMessageToGlobe operation, enabling you to send SMS messages to various regions around the world, excluding the Chinese mainland.

Usage notes

  • When you define a new default profile, the value of the regionId parameter must be ap-southeast-1 and cannot be changed. Note that regionId is the first parameter in the default profile.
  • You must set the domain parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must set the version parameter to 2018-05-01.

Sample code

using System;
using System.Collections.Generic;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;

namespace CommonRequestDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            IClientProfile profile = DefaultProfile.GetProfile("ap-southeast-1", "<accessKeyId>", "<accessSecret>");
            DefaultAcsClient client = new DefaultAcsClient(profile);
            CommonRequest request = new CommonRequest();
            request.Method = MethodType.POST;
            request.Domain = "dysmsapi.ap-southeast-1.aliyuncs.com";
            request.Version = "2018-05-01";
            request.Action = "SendMessageToGlobe";
            request.AddQueryParameters("To", "62123****8901");
            // request.Protocol = ProtocolType.HTTP;
            request.AddQueryParameters("Message", "have a test.");
            try {
                CommonResponse response = client.GetCommonResponse(request);
                Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
            }
            catch (ServerException e)
            {
                Console.WriteLine(e);
            }
            catch (ClientException e)
            {
                Console.WriteLine(e);
            }
        }
    }
}