[PythonCE] Sending SMS messages from PythonCE
Silas S. Brown
ssb22 at cam.ac.uk
Mon Feb 14 13:20:22 CET 2011
Hi, I wonder if you'd like to add this to the examples. It's a
Python function to send an SMS message (text message) from PythonCE.
Tested on Windows Mobile 6.0 Smartphone, should work on most others.
Took me a while to figure out and I thought others might benefit.
import ctypes.wintypes as wintypes
def send_SMS_message(number, unicode_text):
handle = wintypes.DWORD()
ret = ctypes.cdll.sms.SmsOpen(u"Microsoft Text SMS Protocol",
if not (ret==0 and handle): raise Exception("SmsOpen error")
_fields_ = [("smsatAddressType",ctypes.c_int),
("ptsAddress",ctypes.c_wchar * 256)]
unicode_text = u"" + unicode_text # make sure it's Unicode
ret = ctypes.cdll.sms.SmsSendMessage(handle,None,
if not ret==0: raise Exception("SmsSendMessage error")
PS: Thanks for developing PythonCE, much appreciated. I'm using
it for my language-learning program and front-end to eSpeak speech synth
http://people.pwf.cam.ac.uk/ssb22/gradint/ among other things.
Silas S Brown http://people.pwf.cam.ac.uk/ssb22
More information about the PythonCE