C# SMS API reference
'SMSClient' is the namespace of the C# SMS API's class.
Add the following line to include it:
On this page you can find useful properties, methods and events.
By modifying the properties you can log into Ozeki SMS Gateway to send and receive SMS.
'mySMSClient' will be the name of the C# instance used in this reference guide.
ozSMSClient mySMSClient = new ozSMSClient();
- Username: The name of the SMS Gateway user you would like to use for login. Default value: admin
- Password: The password belonging to the username. Default value: abc123
- Host: The IP address of your Ozeki SMS Gateway. Default value: 127.0.0.1
- Port: The port number of Ozeki SMS Gateway's SMPP server. Default value: 9500
- Connected: You can build up a connection by changing this bool value to true. Default value: false
- KeepalivePeriod: The time to wait in seconds between pinging the SMPP server. Default value: 60
- SocketTimeout: The time span to spend on waiting for the login PDU (in seconds). Default value: 10
mySMSClient.Username = "admin";
mySMSClient.Password = "abc123";
mySMSClient.Host = "127.0.0.1";
mySMSClient.Port = 9500;
mySMSClient.Connected = true;
||You can easily send SMS messages with this method.
The recipient's phone number and the text message are mandatory parameters.
You can see the parameters of 'sendMessage' by checking out this page.
||It contains extra parameters compared to 'sendMessage', although both are capable to send SMS messages.
All parameters are mandatory, but you can use "" or NULL at the following parameters:
sender, serviceprovider and optionalParameterList.
Dictionary<string, string> HelloWorld_parameters = new Dictionary<string, string>();
mySMSClient.sendMessageEx("+3670654321", "+3620123456", "Hello world",
"SMS:TEXT", "SMPP0", HelloWorld_parameters);
'mySMSClient' is an example created with the constructor.
Events connected to mySMSClient
mySMSClient.OnClientConnected += new SimpleEventHandler
mySMSClient.OnClientDisconnected += new SimpleEventHandler
mySMSClient.OnClientConnectionError += new ErrorEventHandler
mySMSClient.OnMessageAcceptedForDelivery += new DeliveryEventHandler
mySMSClient.OnMessageDeliveredToNetwork += new DeliveryEventHandler
mySMSClient.OnMessageDeliveredToHandset += new DeliveryEventHandler
mySMSClient.OnMessageDeliveryError += new DeliveryErrorEventHandler
mySMSClient.OnMessageReceived += new DeliveryEventHandler
Events can be shown on the console of your C# application (Figure 1).
Figure 1 - An 'OnClientConnected' event
Now look at the detailed description of each event on the table below:
This event is invoked by your C# application if the connection
to the SMPP server of Ozeki SMS Gateway was successful.
It is invoked if your C# application was disconnected from the SMPP server of Ozeki SMS Gateway.
It is invoked by your C# application if the connection to the SMPP server of Ozeki SMS Gateway was unsuccessful.
It is invoked if the message is accepted for delivery by Ozeki SMS Gateway through a user. The SMS Gateway user must be connected to your C# application
and the user must have enough SMS credits as well.
It is invoked if the GSM network provider accepts the SMS message for delivery.
It is invoked exactly when the SMS message reaches the recipient's mobile phone.
The phone can be out of coverage or can also be turned off, so this event might happen long after
the 'onMessageDeliveredToNetwork' event.
Message delivery error can happen in 3 different situations:
1. There is no recipient with the selected phone number.
2. There is no money on the sender's account.
3. It has been stored on the GSM server for more time then the validity period.
Your Ozeki SMS Gateway can receive SMS messages too. In this case an 'onMessageReceived' event will be invoked for your C# application.
This happens exactly when the message is received by a user of Ozeki SMS Gateway. This user must be connected to the C# SMS API.