Page 1 of 1

NullReferenceException on SubmitSM.ShortMessage

Posted: Tue May 29, 2012 3:57 am
by Alon
Hi,

I'm trying to send a single message using SubmitAsync So I have created a SubmitSM object using this constructor:
SubmitSm Constructor (String, Byte, Byte, String, Byte, Byte, String)
then I fill the various fields like RegisteredDelivery, DataCoding, PriorityFlag, ValidityPeriod and ShortMessage but when I'm trying to set the message's text to the ShortMessage property, I'm getting NullReferenceException (Object reference not set to an instance of an object). Any idea?

As far as I got from the sample and documentation, the PrepareSubmit is more for destination list and the SubmitText is for long messages.
I'm sure I can use either of them but it seems to me a bit of overhead if I need to send only a short, single message. Am I wrong?

Thanks.

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Tue May 29, 2012 5:44 pm
by Alon
BTW, a workaround will be to use this:
SubmitSM.ShortMessageBytes = Client.GetMessageBytes([message], [DataCoding])

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Tue May 29, 2012 7:47 pm
by alt
PrepareSubmit method only generates SubmitSm or SubmitMulti list. This method doesn't send messages.
SubmitText uses PrepareSubmit, but also sends messages. These methods help to send concatenated messages (longer 140 bytes).

I would suggest to use following code for single messages:
SubmitSM.UserDataPdu.ShortMessage = Client.GetMessageBytes([message], [DataCoding])

because in version 1.1 properties SubmitSM.ShortMessage and SubmitSM.ShortMessageBytes are obsolete.

And please remember that you cannot send message longer than 140 bytes in one message.

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Tue May 29, 2012 8:14 pm
by Alon
because in version 1.1 properties SubmitSM.ShortMessage and SubmitSM.ShortMessageBytes are obsolete.
Thanks. Good to know.

If I define the DataCoding in the ShortMessage, do I need to define it again in the SubmitSM.DataCoding property?
And please remember that you cannot send message longer than 140 bytes in one message.
Yes, but I have a question about this - when writing SMS in my phone - I have 160 chars per SMS if I use English or Spanish chars. Any other type of chars automatically reduce the allowed length to 70. I can understand the 70 as every special char requires 2 bytes, so 140/2=70. But how the En/Sp allow 160? And if my SMS are always in Spanish, can't I send 160 chars (bytes)? I'm using the Latin1 encoding (correct?)

Thanks.

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Wed May 30, 2012 7:30 pm
by alt
in code Client.GetMessageBytes([message], [DataCoding]) you convert only text to bytes using specified datacoding.
You need to define encoding in submitSm.DataCoding property.

You can send 160 chars per SMS only when you use packed GSM encoding. You can enable it with code

Code: Select all

client.MapEncoding(DataCodings.Latin1, new Inetlab.SMPP.Encodings.GSMPackedEncoding());

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Wed May 30, 2012 9:19 pm
by Alon
Thanks!
You can send 160 chars per SMS only when you use packed GSM encoding. You can enable it with code

Code: Select all

CODE: SELECT ALL
client.MapEncoding(DataCodings.Latin1, new Inetlab.SMPP.Encodings.GSMPackedEncoding());
Does this feature depends on the provider?

BTW, it is a very important piece of information :) I would add it in the FAQ section...

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Thu May 31, 2012 7:26 am
by alt
Yes, you need to ask provider for which data_coding they support packed GSM encoding.

Re: NullReferenceException on SubmitSM.ShortMessage

Posted: Thu May 31, 2012 1:57 pm
by Alon
Thanks.