Avatar of ITsolutionWizard
ITsolutionWizard
Flag for United States of America asked on

C# with SMS Texting

The following codes written in c# with Twilio is working okay.
But I want to read Twilio's status (e.g. sent, error)
and I try message.status and it does not working.
do you know how to check the message status?

I expect to something like below

if  (message.status == "sent")
{
UpdateSMSInfo(s);
}

Open in new window


 public static int SendSMSInBulk(Domain.SMS s)
        {
            string str = string.Empty;
            int count = 0;
            string phoneListStr = string.Empty;
            foreach (Domain.SMS smsInfo in MasterHelper.SMS.GetPhoneNoList(s))
            {
                str = str + "+1" + smsInfo.MobilePhoneNo + ",";
            }
            if (str != "")
            {
                phoneListStr = str.Remove(str.Length - 1);
                TwilioClient.Init(TwilioSID, TwilioToken);
                var numbersToMessage = new List<string>
                {
                //"+13105975782",               
                 phoneListStr
                };
               foreach (var number in numbersToMessage)
                    {
                        var message = MessageResource.Create
                        (
                            body: s.Message,
                            from: new Twilio.Types.PhoneNumber("+1" + TwilioPhoneNo),
                            to: new Twilio.Types.PhoneNumber(number) //member's mobile phone no
                        );
	                #region check if i can use status                    

                        s.MobilePhoneNo = number.Replace("+1", string.Empty);

                        UpdateSMSInfo(s);
                        count = count + 1;
                        #endregion
                } 
            }    
            return count;
        }

Open in new window

C#* SMS* Twilio

Avatar of undefined
Last Comment
Eduard Ghergu

8/22/2022 - Mon
ITsolutionWizard

ASKER
Any helps?
ASKER CERTIFIED SOLUTION
Eduard Ghergu

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61