Can't send more than 160 characters sms C# using GSM Modem

南楼画角 提交于 2019-12-02 19:02:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!