Class SmsClient
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
credsCredentialsOptional 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
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
fromstringThe name or number the message should be sent from. Alphanumeric sender IDs are not supported in all countries.
tostringThe recipient phone number in E.164 format (e.g., 447700900000).
textstringThe body of the message. Use Unicode for messages containing non-GSM characters.
typeSmsTypeThe format of the message body. Defaults to Text.
credsCredentialsOptional 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
requestSendSmsRequestThe SMS request containing message details.
credsCredentialsOptional 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