我已经尝试了几个星期但仍然无法弄清楚如何从SMSC发送短信后收到送达消息。我使用过Intelab SMPP并开发了一个短信系统。我使用以下代码来获取交货收据,我使用MessageId成功收到了收据。
public static IList<SubmitSmResp> ConnectToInet(string sourceAddress, string DestinationAddress, string Message)
{
try
{
SmppClient client = new SmppClient();
IList<SubmitSmResp> respList = null;
client.Connect(#SMSSeverIP, #PORT);
if (client.Status == Inetlab.SMPP.Common.ConnectionStatus.Open)
{
client.Bind("USERNAME", "Password", Inetlab.SMPP.Common.ConnectionMode.Transceiver);
if (client.Status == Inetlab.SMPP.Common.ConnectionStatus.Bound)
{
client.AddrTon = 5;
respList = client.Submit(
SMS.ForSubmit().From(sourceAddress).To(DestinationAddress).Text(Message).DeliveryReceipt().Coding(DataCodings.Default)
);
//client.Submit(SMS.ForSubmit().Text(Message).From(sourceAddress).To(DestinationAddress).DeliveryReceipt().Coding(DataCodings.Default));
client.evDeliverSm += new Inetlab.SMPP.Common.DeliverSmEventHandler(OnDeliverSm);
client.UnBind();
}
client.Disconnect();
}
return respList;
}
catch (Exception ex)
{
throw ex;
}
}
我的DeliverSm方法用于获取送货回执,我已能够成功收到送货回执。
private static void OnDeliverSm(object sender, DeliverSm data)
{
string messageText = data.Client.GetMessageText(data.UserDataPdu.ShortMessage, data.DataCoding);
}
我已经从每个SMSC响应中存储了收到的MessageId,我需要使用它来获取每条消息的相应发送报告,其中包含发送状态,发送日期和提交日期。有人可以帮我解决这个问题。谢谢你的帮助!