WM6 SmsMessage object sends unicode text messages When sending an SMS from a C# application on our new Motorola Q9m, I find that I can only send 70-80 characters. If I send more than 70-80 characters, I get "Error sending Sms Message" when the Send() method is executed. To send the full 160 characters usually available in an SMS message, I need the SmsMessage object to encode the sms.Body property as a GSM (7-bit ASCII) encoded type. Apparently, the Pocket Outlook SmsMessage object's Body property defaults to UCS-2(Unicode) on both the Q9m phone and on Microsoft's WM6 emulators. 1. Can anyone tell me how to set the encoding type for the sms.Body property using managed code? Since my application must run on different phones, and I may have to programmatically limit characters per message to less than 160 or 80 depending on: a. whether the sms.Body encoding is GSM or USC-2 b. on whether the language of the message is English or an International c. on whether the phone is WM5 or WM6 based (when the SmsMessage object is used under WM5 the encoding is apparently GSM) 2. Can anyone tell me how to determine what encoding the sms.Body property is using? 3. Finally, Verizon or other servers that relay text messages seem to have limits on the length of USC-2 messages, I found that the message can be short enough to send using the SmsMessage object, but too long to be relayed successfully from my phone to the target phone. A message of length of 69 characters does successfully reach the destination phone. Any thoughts on carrier handling of USC-2 would be appreciated. The Q9m has WM6 and the 2.0 compact framework. The code which replicates the problem is simple: ... using Microsoft.WindowsMobile.PocketOutlook; ... try{ SmsMessage sms = newSmsMessage(); sms.Body = "0123456789012345678901234567890123456789...[70 or more characters]"; sms.To.Add(newRecipient("15555551212")); sms.Send(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } There are a number of unmanaged examples on the web that allow the explicit setting of the text message encoding (search for SMSDE_OPTIMAL). But I would like to avoid unmanaged code if possible.
Last edited by somuch; 04-25-2008 at 06:13 PM.
Reason: clarify payload for sms.Body property
|