I finally found a solution
CODE:
protected void ButtonSms_Click(object sender, EventArgs e)
{
SendSms();
}
public void SendSms()
{
try
{
// Twilio credentials
string accountSid = "ACf3e50202f5988c915d37e995a62b51ec"; // Replace with your Account SID
string authToken = "166eb90fe50b38b7ba1bb4d841852ec8"; // Replace with your Auth Token
// Get the phone number and message text from the TextBox controls
string toPhoneNumber = DestinationNumber.Text;
string messageBody = SMSmessage.Text;
// Your Twilio phone number (must be SMS-enabled)
string fromPhoneNumber = "+13232489076"; // Replace with your Twilio number
// Initialize the Twilio client
TwilioClient.Init(accountSid, authToken);
// Send the SMS
var message = MessageResource.Create(
to: new PhoneNumber(toPhoneNumber),
from: new PhoneNumber(fromPhoneNumber),
body: messageBody
);
// Optionally, show a success message
Response.Write("<script>alert('Message sent! SID: " + message.Sid + "');</script>");
}
catch (Exception ex)
{
Response.Write("<script>alert('Error: " + ex.Message + "');</script>");
}
}