2016-01-21 78 views
2

這裏是我的代碼:如何在GSMComm庫中連接長的SMS?

根據這一pageCreateConcatTextMessage方法返回SmsSubmitPdu[]類型的數組,但是,當我嘗試用SendMessages發送,我收到了MessageServiceError 500。我錯過了什麼?

 SmsSubmitPdu[] pdu2; 

     try{ 
      pdu2 = SmartMessageFactory.CreateConcatTextMessage("My name is Barry Allen. And I am the fastest man alive. When I was a child I saw my mother killed by something impossible. My father went to prison for her murder.", "+639234597676"); 
      comm.SendMessages(pdu2); 
     } 

     catch (MessageServiceErrorException e500){ 
      MessageBox.Show(e500.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
     } 
     catch (CommException e501){ 
      MessageBox.Show(e501.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
     } 

回答

-1

輸入沒有縣代碼的號碼。

messageToSend = "lONG MESSAGE >160"; 
mobileNo = ""; 
SmsSubmitPdu[] pdu2; 
pdu2 = GsmComm.PduConverter.SmartMessaging.SmartMessageFactory.CreateConcatTextMessage(messageToSend, mobileNo); 
//comm.SendMessage(pdu1); 
comm.SendMessages(pdu2); 
1

您的代碼應該是這樣的:

GsmCommMain comm=new GsmCommMain(/*Set your option here*/); 

string txtMessage="your long message..."; 
string txtDestinationNumbers="your destination number"; 

//select unicode option by a checkBox or any other control 
bool unicode = chkUnicode.Checked; 

SmsSubmitPdu[] pdu = SmartMessageFactory.CreateConcatTextMessage(txtMessage, unicode, txtDestinationNumbers); 
CommSetting.comm.SendMessages(pdu);