C# SMS API message class
The sms messages class in the C# sms api is responsible for carrying a message between the C# sms api application and the Ozeki SMS Gateway. This is the class you pass to the Client.Send() method when you wish to send an SMS through the C#/Net SMS API.
C# sms api / SMS message ID
ID: The message ID is used to identify the SMS. This ID is returned for sms submit reports and sms delivery reports.
C# sms api / SMS sender ID
FromConnection: The name of the SMS mobile network connection where the SMS came into the Ozeki SMS Gateway. For example if you connect to the mobile network using an SMPP client connection the will be "SMPPClient1" when an SMS comes in on that connection. If you use an Android SMS gateway, this would be "Vodafone UK" if the SMS came in through the SIM card serving the vodafone network
FromAddress: The sender ID of the SMS message. If the SMS was sent from a mobile phone with the number +44123467 this property will hold the value +44123467. If you want to specify a custom sender ID from an SMS you wish to send this is the property you should set. You can put a phone number into this field, an SMS shortcode associated with C# SMS API, or an alphanumeric sender id identifying the C# SMS API.
FromStation: This is the ID of the SMS gateway computer that the received the SMS. Every Ozeki SMS Gateway has a unique global id (GUID). If your C# API connects to multiple SMS Gateway this ID is useful to identify where the SMS message comes from.
C# sms api / SMS recipient
ToConnection: Use this field if you wish to override the SMS routing table in the SMS Gateway. You can specify the name of the SMS mobile network connection to use for SMS delivery in this field.
ToAddress: The phone number where the SMS should be sent to. If you want to send a text message to the mobile phone +3620123456, put +3620123456 into this field. This field is mandatory for outgoing SMS messages.
ToStation: This field can be used if you want to forward your SMS through a particular SMS gateway. This field is only relevant if you work with multiple SMS Gateways. It is safe to leave it empty.
C# sms api / SMS text
Text: This field where you should put the message text. This field can contain messages up to 65 536 characters. If the message length is longer than 160 characters, your SMS will be sent as a multi part SMS message. This field is mandatory for every SMS message.
C# sms api / Dates
CreateDate: This timestamp is automatically set to Datetime. Now when an instance of the messages class is created.
ValidUntil: Set this time in you C# SMS api implementation, to specify an expiry date for the SMS. If your SMS is expired, it will be removed from the outbox folder. This date is also used in setting the validity period for the SMS before it is sent to the mobile network
TimeToSend: To schedule an SMS from future delivery in your C# SMS API, set this date to a future point in time. Your SMS message will stay in the SMS Gateway out box until the time comes to send it. (Note that the Ozeki SMS Gateway is an SMS server which means it is able to store and forward your SMS messages).
C# sms api / Delivery report request
IsSubmitReportRequested: Set this to true if you wish to receive a SubmitAccepted report in your C# SMS api implementation.
IsDeliveryReportRequested: Set this to true if you wish to receive a Delivery report in your C# SMS api implementation.
IsViewReportRequested: Set this to true if you wish to receive a view report in your C# SMS api implementation. Note the view reports for SMS messages are not returned by the mobile network. The view report is used if you send your messages to chat recipient, and the recipient view your messages in the chat app.
C# sms api / Tags
Tags: Message tags are optional fields. You can specify fields in the name/value format. This list of additional parameters can be used to specify custom values used in SMS transmission, such as raw PDU, data coding scheme, SMS port numbers and other similar values, that can be used for encoding.
C# sms api message class source
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OZX { public class OzxMessage : IOzxMessage { public string ID { get; set; } public string FromConnection { get; set; } public string FromAddress { get; set; } public string FromStation { get; set; } public string ToConnection { get; set; } public string ToAddress { get; set; } public string ToStation { get; set; } public string Text { get; set; } public DateTime CreateDate { get; set; } public DateTime ValidUntil { get; set; } public DateTime TimeToSend { get; set; } public bool IsSubmitReportRequested { get; set; } public bool IsDeliveryReportRequested { get; set; } public bool IsViewReportRequested { get; set; } //********************************************** // Optional tags //********************************************** static Dictionary<string, string> _tags; static Dictionary<string, string> Tags { get { return _tags ?? (_tags = new Dictionary<string,string>()); } } public Dictionary<string, string> GetTags() { lock (Tags) { return Tags.ToDictionary(entry => entry.Key, entry => entry.Value); } } public void AddTag(string key, string value) { lock (Tags) { if (Tags.ContainsKey(key)) Tags[key] = value; else Tags.Add(key, value); } } //********************************************** // Construction //********************************************** public OzxMessage() { ID = Guid.NewGuid().ToString(); CreateDate = DateTime.Now; TimeToSend = DateTime.MinValue; ValidUntil = DateTime.Now.AddDays(7); IsSubmitReportRequested = true; IsDeliveryReportRequested = true; IsViewReportRequested = true; } //********************************************** // To string //********************************************** public override string ToString() { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(FromAddress)) sb.Append(FromAddress.ToString()); else sb.Append(FromConnection); sb.Append("->"); if (!string.IsNullOrEmpty(ToAddress)) sb.Append(ToAddress.ToString()); else sb.Append(ToConnection); if (Text != null) { sb.Append(" '"); sb.Append(Text); sb.Append("'"); } return sb.ToString(); } } }
More information
- How to send SMS from C#
- Receive SMS in C#
- C# SMS API connect to send SMS
- C# SMS API - disconnect from SMS gateway
- C# SMS API - keepalive SMS connection alive
- C# SMS API - send a text message
- C# SMS API - SMS accepted for deliery event
- C# SMS API - SMS not accepted for delivery
- C# SMS API - submited
- C# SMS API - submit failed
- C# SMS API - delivery report successful
- C# SMS API - delivery failed report
- C# SMS API - alphanumeric sender ID
- C# SMS API how to use short code as sender ID
- C# SMS API text message class