【问题标题】:Send SMS with Delivery Report发送带有送达报告的短信
【发布时间】:2016-08-04 20:17:53
【问题描述】:

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

【问题讨论】:

标签: c# sms windows


【解决方案1】:

您首先阅读 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()


      }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多