Table of Contents

Class SmsClient

Namespace
Vonage.Messaging
Assembly
Vonage.dll

Implementation of ISmsClient for sending SMS messages via the Vonage SMS API.

public class SmsClient : ISmsClient
Inheritance
SmsClient
Implements
Inherited Members

Constructors

SmsClient(Credentials)

Initializes a new instance of the SmsClient class.

public SmsClient(Credentials creds = null)

Parameters

creds Credentials

Optional credentials to use for API requests.

Properties

Credentials

Gets or sets the credentials used to authenticate API requests.

public Credentials Credentials { get; set; }

Property Value

Credentials

Methods

SendAnSmsAsync(string, string, string, SmsType, Credentials)

Sends an outbound SMS message from your Vonage account using simple parameters.

public Task<SendSmsResponse> SendAnSmsAsync(string from, string to, string text, SmsType type = SmsType.Text, Credentials creds = null)

Parameters

from string

The name or number the message should be sent from. Alphanumeric sender IDs are not supported in all countries.

to string

The recipient phone number in E.164 format (e.g., 447700900000).

text string

The body of the message. Use Unicode for messages containing non-GSM characters.

type SmsType

The format of the message body. Defaults to Text.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<SendSmsResponse>

A SendSmsResponse containing the message status and details.

Examples

var response = await client.SmsClient.SendAnSmsAsync(
    from: "Vonage",
    to: "447700900000",
    text: "Hello from Vonage!"
);
Console.WriteLine($"Message sent: {response.Messages[0].MessageId}");

Exceptions

VonageSmsResponseException

Thrown when the SMS request fails or returns a non-zero status.

See Also

SendAnSmsAsync(SendSmsRequest, Credentials)

Sends an outbound SMS message from your Vonage account.

public Task<SendSmsResponse> SendAnSmsAsync(SendSmsRequest request, Credentials creds = null)

Parameters

request SendSmsRequest

The SMS request containing message details.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<SendSmsResponse>

A SendSmsResponse containing the message status and details.

Examples

var request = new SendSmsRequest
{
    From = "Vonage",
    To = "447700900000",
    Text = "Hello from Vonage!"
};
var response = await client.SmsClient.SendAnSmsAsync(request);
Console.WriteLine($"Message ID: {response.Messages[0].MessageId}");

Exceptions

VonageSmsResponseException

Thrown when the SMS request fails or returns a non-zero status.

See Also