NullReferenceException on SubmitSM.ShortMessage

.NET library for SMPP protocol
Locked
Alon
Posts: 8
Joined: Mon May 07, 2012 4:26 pm

NullReferenceException on SubmitSM.ShortMessage

Post by Alon » Tue May 29, 2012 3:57 am

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.
Alon
Posts: 8
Joined: Mon May 07, 2012 4:26 pm

Re: NullReferenceException on SubmitSM.ShortMessage

Post by Alon » Tue May 29, 2012 5:44 pm

BTW, a workaround will be to use this:
SubmitSM.ShortMessageBytes = Client.GetMessageBytes([message], [DataCoding])
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: NullReferenceException on SubmitSM.ShortMessage

Post by alt » Tue May 29, 2012 7:47 pm

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.
Alon
Posts: 8
Joined: Mon May 07, 2012 4:26 pm

Re: NullReferenceException on SubmitSM.ShortMessage

Post by Alon » Tue May 29, 2012 8:14 pm

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.
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: NullReferenceException on SubmitSM.ShortMessage

Post by alt » Wed May 30, 2012 7:30 pm

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());
Alon
Posts: 8
Joined: Mon May 07, 2012 4:26 pm

Re: NullReferenceException on SubmitSM.ShortMessage

Post by Alon » Wed May 30, 2012 9:19 pm

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...
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: NullReferenceException on SubmitSM.ShortMessage

Post by alt » Thu May 31, 2012 7:26 am

Yes, you need to ask provider for which data_coding they support packed GSM encoding.
Alon
Posts: 8
Joined: Mon May 07, 2012 4:26 pm

Re: NullReferenceException on SubmitSM.ShortMessage

Post by Alon » Thu May 31, 2012 1:57 pm

Thanks.
Locked