C# SMS API delivery failed

SMS delivery reports for failed SMS messages are handled the same way in the C# SMS API as SMS delivery reports for successful SMS delivery. The only difference is that the Ozeki SMS gateway raises the OnMessageDeliveryFailed event, and it attaches an error message to the report if the mobile network returns a delivery report with a failed status.

C# SMS API - sms delivery failed
Figure 1 - C# SMS API - sms delivery failed

The C#/.Net SMS api sms delivery failed event

The sms delivery failed event in the C# SMS api arrives when the mobile network considers an SMS message undeliverable. This can happen if the destination mobile phone is never switched on or is roaming in an unaccessible network. Some SMS service providers do not send SMS delivery reports with failed status codes.

To handle the SMS delivery failed report in your C# SMS API follow these steps:

  • Subscrbe for the OnMessageDeliveryFailed event in your C# SMS API class
  • Write the C# code to process the SMS delivery failed report
  • Send an SMS, and save the sms message ID.
  • Process the incoming SMS delivery failed report in your C# sms api class

C# sms api sms delivery failed report example:

Client.OnMessageDeliveryFailed += Client_OnMessageDeliveryFailed;

static void Client_OnMessageDeliveryFailed(object sender, OzxArgs<string, DateTime, string> e)
    Console.WriteLine("Message delivery failed. ID: " + e.Item1 + " Date: " + e.Item2 + " Reason: " + e.Item3);

The C#/.NET sms api receives the date of failure and the error code in addition to the SMS messages ID of the originally sent SMS message.

For Android SMS Gateway setups, you receive this event, when the android phone receives the delivery failed report. If your SMS Server runs on a PC, this SMS delivery failed event will be triggered when the delivery failed report is received on the configure mobile network connection.

More information