Sending SMS and Checking Status Using the SMPP Component


The SMPP component can be used to send SMS messages and check their delivery status. To send a message, connect to an SMPP server by configuring properties such as SMPPServer, SMPPPort, user credentials, and optionally SystemType, then specify the recipient and message content.

For example:

smpp.SMPPServer = "smpp.smppserver.com";
smpp.SMPPPort = 1234;
smpp.AddRecipient(0, "19195555555");
smpp.Connect("username", "password");
smpp.SendMessage("Lets have lunch!");

To check the status of a previously sent message, use the CheckMessageStatus method with the message ID returned by SendMessage. The component retrieves the last known status of the message stored on the server under MessageId and fires a MessageStatus event containing the parsed response from the server.

The MessageStatus event provides MessageState (the last known state of the message on the SMPP server), MessageError (an error code for any delivery failure, which may be vendor-specific), and FinalDate (a human-readable string of the delivery date, empty if the message was not delivered).

For example:

smpp.CheckMessageStatus(MessageId);

Handle the result in the MessageStatus event:

smpp.OnMessageStatus += (s, e) => {
    Console.WriteLine("State: " + e.MessageState);
    Console.WriteLine("Error: " + e.MessageError);
    Console.WriteLine("Final Date: " + e.FinalDate);
};

This allows you to both send SMS messages and monitor their delivery programmatically.

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.