This topic describes how to use SMS SDK for C# to call the SendMessageToGlobe operation. This API operation allows you to send text messages to regions outside mainland China.

Request parameters

Parameter Type Required Example Description
To String Yes 45***0121 You can call the SendMessageToGlobe operation to send text messages to only one mobile phone number. You must add the country code to the beginning of the mobile phone number.
From String No abc1**** You can specify the sender ID when you call the API operation. The sender ID can contain digits and letters. If the sender ID contains only letters, the sender ID can be a maximum of 11 characters in length. If the sender ID contains only digits, the sender ID can be a maximum of 15 characters in length.
Message String Yes Hello The content of the text message.

Response parameters

Parameter Type Example Description
MessageId String 10080303003003 The ID of the delivery receipt. You can query the status of the text message based on this parameter.
To String 13900001234 The mobile phone number that received the text message.
From String Alicloud The sender ID of the text message.
ResponseCode String OK The status code of the request. If OK is returned, the request is successful. For more information, see Error codes.
ResponseDescription String The SMS Send Request was accepted The description of the status code.
Segments String 1 The number of the text messages that incurred fees.
NumberDetail String The details of the mobile phone number.
Country String Hongkong, China The country to which the mobile phone number belongs.
Region String HongKong The region to which the mobile phone number belongs.
Carrier String CMI The carrier that provides the mobile phone number.

Install the core library of Alibaba Cloud SDK for C#

Sample requests

Take note of the following information:

  • When you initialize the IClientProfile class, the value of the regionId parameter must be ap-southeast-1 and cannot be modified.
  • You must set the domain parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must set the version parameter to 2018-05-01.
using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;

namespace CommonRpc
{
    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
            {
                Method = MethodType.POST,
                Domain = "dysmsapi.ap-southeast-1.aliyuncs.com",
                Version = "2018-05-01",
                Action = "SendMessageToGlobe"
            };
            // request.Protocol = ProtocolType.HTTPS;
            request.AddQueryParameters("To", "6212345678901");
            request.AddQueryParameters("PhoneNumber", "PhoneNumber");
            // request.AddQueryParameters("From", "1234567890");
            request.AddQueryParameters("Message", "have a test.");

            try
            {
                CommonResponse response = client.GetCommonResponse(request);
                Console.WriteLine(response.Data);
            }
            catch (ServerException e)
            {
                Console.WriteLine(e);
            }
            catch (ClientException e)
            {
                Console.WriteLine(e);
            }
        }
    }
}