Search code examples
c#gsm

Send Sms using gsm modam using c# and message length is too short


I build an SMS app in C# but when I sent a message only 150 char message get sent. But my client requirement is to send more than 150 char.

How I can do solve?


Solution

  • You can get the count of the string before sending the message/SMS and then Spilt them based on the character count and send it separately.

     string strValue = "qwertyui oplkjhgfds azxcvb nm,. ;'[poerern asyqawqwdhkas,mdbn ahwdasda doiashdkjabdamd aiuasdghkjabdan dakshdkajdbkasdvsa askldhkajdahvd asdhkakjdad kahsdjbajkdbasd";
     int nLength = strValue.Length;
    
     if (nLength > 150)
     {
        //You can give the count in which you want to spilt the string
        var regex = new Regex(@".{100}");
        string result = regex.Replace(strValue, "$&" + Environment.NewLine+ Environment.NewLine);
        MessageBox.Show(result);
     }
    

    Output result

    String spilt based on character count