Table of Contents

Create and send messages

There are several ways to create a message. The most convenient way is by using helper class SMS:

IList<SubmitSm> pduList = SMS.ForSubmit().From("111").To("79171234567").Text("Hello World!").Create(_client);

This example will produce a collection pduList containing single short message. If the message is longer when 140 octets, it will be automatically split to parts. All message parts are also placed into a collection IList<SubmitSm>. The mobile phone automatically concatenates received message parts into a single longer message.

The library also provides a way to create SumitSm PDU manually:

public SubmitSm CreateSubmitSm()
{
    SubmitSm sm = new SubmitSm();
    sm.UserData.ShortMessage = _client.EncodingMapper.GetMessageBytes("Test Test Test Test Test Test Test Test Test Test", DataCodings.Default);
    sm.SourceAddress = new SmeAddress("1111", AddressTON.NetworkSpecific, AddressNPI.Unknown);
    sm.DestinationAddress = new SmeAddress("79171234567", AddressTON.Unknown, AddressNPI.ISDN);
    sm.DataCoding = DataCodings.UCS2;
    sm.SMSCReceipt = SMSCDeliveryReceipt.SuccessOrFailure;

    return sm;
}

This method does not have support for long messages and splitting. However, when you need to create Inetlab.SMPP.PDU messages and set properties not supported by SMS class this method is very useful.

Actual message transmission is performed by calling method SubmitAsync and passing either an argument of SubmitSm PDU either arrays/collections using method overloads.

IEnumerable<SubmitSmResp> responses = await _client.SubmitAsync(pduList);

The SubmitAsync method supports batch sending. It is possible to send pduList containing thousands of PDUs by a single call to SubmitAsync method. The method will return results after SmppClient have received server responses for all Inetlab.SMPP.PDU's sent.

Please note, the order of SubmitSmResp in response collection may not match the order of PDUs in pduList collection. The relation between commands sent and server responses may be established by resp.Header.Sequence property.

Successful processing of SubmitSm on server side produces server response containing status response.Header.Status = ESME_ROK.

It is possible that several SubmitSmResp will produce a response with error status: