通过发送报告发送短信

时间:2010-12-24 13:12:05

标签: c# sms windows

我使用GSM Communication Library (GSMComm)发送和接收带有GSM调制解调器的短信。如何通过发送报告发送短信?如何获取发送消息的状态?

1 个答案:

答案 0 :(得分:4)

您首先阅读来自SIM的所有消息(因为状态报告消息将作为短信从您使用的提供商发送回您的SIM)。
迭代这些消息并过滤出状态消息。
您必须已从移动设备保存已发送短信的ID data.Status.ToString()

GsmCommMain comm = new GsmCommMain(port, baundRate, timeout);
//.... Other code may goes here
// Read all SMS messages from the storage
    DecodedShortMessage[] messages = comm.ReadMessages(PhoneMessageStatus.All, 
    PhoneStorageType.Sim );// Or PhoneStorageType.Phone
    foreach (DecodedShortMessage message in messages)
        {
          if (((SmsPdu)message.Data) is SmsStatusReportPdu)
          {
                //HERE WE'LL GET THE STATUS REPORT
                SmsStatusReportPdu data = (SmsStatusReportPdu)message.Data;
                //Recipient: data.RecipientAddress
                //Status: data.Status.ToString()
                //Timestamp: data.DischargeTime.ToString()
                //Message ref (ID of the sent sms from the mobile): data.MessageReference.ToString()


      }
    }