问题
I have searched a lot but still couldn't find exactly what am looking for. Actually i'm working on a winforms app that will allow user to send bulk sms using GSMCOMM library with the help of a GSM Modem. What i have achieved so far is that i can send text messages that are <= 160 characters but problem begins when a message gets longer that 160 characters. I don't get any error and sms seemed to have been sent but its not actually. I'm sharing my code snippet that is used to send sms. Please have a look at it and let me know where the problem is. Thanks.
SmsSubmitPdu[] pdus;
comm.Open();
pdus = SmartMessageFactory.CreateConcatTextMessage(message, number);
comm.SendMessages(pdus);
comm.Close();
回答1:
Alright, so after lots and lots of effort, research and minor change in the code i have got the solution and now it's working perfectly. I'm posting the solution that worked for me and I hope it will also help those who face the same problem.
Please make sure that the GSMCOMM library is up-to-date i.e. version 1.21.0 otherwise it may not work properly.
This is the correct code snippet. It will send short messages (i.e. less or equal to 160 chars) as well as long text message (i.e. more than 160 chars) as a single sms.
OutgoingSmsPdu[] pdus = null;
comm.Open();
pdus = SmartMessageFactory.CreateConcatTextMessage(message, number);
comm.SendMessages(pdus);
comm.Close();
来源:https://stackoverflow.com/questions/51136293/cant-send-more-than-160-characters-sms-c-sharp-using-gsm-modem