Sending SMS Error

Dino Giuditta 20 Reputation points
2024-05-14T07:43:03.4033333+00:00

Good morning Microsoft Support Team, I hope you can help me.

I'm trying to use Azure Communication Service to send SMS. I purchased your Sender ID. In my web application with Framework 4.6.1 (not .NET Core) in C# I'm using your sample lines of code:

///////////////////////////////////////////////

using Azure.Communication.Sms;

SmsClient smsClient = new SmsClient(connStr);

        SmsSendResult sendResult = smsClient.Send(

        from: "XXX",

        to: "YYY",

        message: "ZZZ"

        );

///////////////////////////////////////////////

but I get the following error:

on localhost:

"Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy."

on the server:

The type initializer for "Azure.Core.ClientOptions" threw an exception.'

Can you tell me something more? Is this an already known and resolved error?

I didn't find any answers or solutions in the https://learn.microsoft.com forum

Thank you!!

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
713 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 18,871 Reputation points
    2024-05-21T09:01:47.8566667+00:00

    @Dino Giuditta Glad that you were able to resolve your issue and I appreciate your effort in sharing the solution.

    Your contribution will undoubtedly assist others facing similar challenges.

    As the Microsoft Q&A community follows a policy where the question author cannot accept their own answer , I've reposted your solution. 

    Feel free to consider "Accepting" the answer if you find it suitable.  

    Resolution- It's necessary to add below line of code before the "Send" method:

    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

    Thanks again.

    0 comments No comments