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 Gateawy. 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 wan 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 usefult to identy 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 gatewy. 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 then 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 Gateawy 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 paramteres 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;
                    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))
            if (!string.IsNullOrEmpty(ToAddress))

            if (Text != null)
                sb.Append(" '");
            return sb.ToString();


More information