Click here to Skip to main content
15,917,174 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
I want to send 400 character sms using gsm moden d link dwn 157 c# if err then repet send


What I have tried:

I want to send 400 character sms using gsm moden d link dwn 157 c# if err then repet send
Posted
Updated 14-Mar-16 0:37am
Comments
Afzaal Ahmad Zeeshan 13-Mar-16 15:01pm    
Then? What is the problem? Most of the times the source code required is almost packaged with the user guide or is explained in the development tools.
IrfanfromMultanPakistan 13-Mar-16 16:12pm    
i want to send 500 words sms but this code send only 160 words

private void SendSMS(string message, string Numbers)
{
string indataa = Port.ReadExisting();

if (Port.IsOpen)
{
//SerialPort Port = (SerialPort);

string indataaa = Port.ReadExisting();

// MessageBox.Show(indata);
Port.Write("AT" + Environment.NewLine);
System.Threading.Thread.Sleep(100);
Port.Write("AT+CMGF=1" + Environment.NewLine);
System.Threading.Thread.Sleep(100);
Port.Write("AT+CFUN=1" + Environment.NewLine);
Port.Write("AT+CMGS=" + (char)34 + Numbers + (char)34 + Environment.NewLine);
System.Threading.Thread.Sleep(100);
Port.Write(message + (char)26 + Environment.NewLine);
// Port.Write(MyMessage + Environment.NewLine + (char)(26));
System.Threading.Thread.Sleep(300);
System.IO.StreamWriter file2 = new System.IO.StreamWriter(@"D:\file.txt", true);
file2.WriteLine("Port" + DateTime.Now + "=" + "Mobile No =" + Numbers);
file2.Close();
// MessageBox.Show(indata);
// Port.Close();
i want to send 500 words sms but this is for only 160 words
Mohammad Reza Valadkhani 14-Mar-16 5:28am    
you have to create message part, for sending big message you have to create msg part
IrfanfromMultanPakistan 14-Mar-16 5:34am    
how to plz tel me how to send parts and plz tech me how to plz
Mohammad Reza Valadkhani 14-Mar-16 5:27am    
There is many choices to do that, you can do it by AT Commands over serial port or some third-party Library that have predefined code like GSMCOMM

1 solution

You can use this (GSMCOMM) library, please consider for sending long messages you have to create multiple pdu mesage this link, please download it, the packages contains sample and information enough for your problem
it support also GSM modems.
SMS libraries (for GSM phones)[^]

Sample
C#
#region MultipleMessaging
private SmsSubmitPdu[] CreateConcatMessage(string message, string number, bool unicode, bool showParts)
{
    SmsSubmitPdu[] pdus = null;
    try
    {
        if (!unicode)
        {

            pdus = GsmComm.PduConverter.SmartMessaging.SmartMessageFactory.CreateConcatTextMessage(message, number);
        }
        else
        {

            pdus = GsmComm.PduConverter.SmartMessaging.SmartMessageFactory.CreateConcatTextMessage(message, true, number);
        }
    }
    catch (Exception ex)
    {
        //MessageBox.Show(ex.ToString());
        return null;
    }



    return pdus;
}

private void SendMultiple(SmsSubmitPdu[] pdus)
{


    try
    {
        // Send the created messages

        foreach (SmsSubmitPdu pdu in pdus)
        {

            mainComminucator.SendMessage(pdu);
        }

    }
    catch (Exception ex)
    {
        ///MessageBox.Show("ERROR" + ex.ToString());
    }


}
#endregion
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900