Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

PyS60 - listSMS to File.txt

// Salva la lista degli SMS in un file

from time import ctime

import codecs
import inbox

box = inbox.Inbox()
msg = box.sms_messages()

f = codecs.open('E:/Others/listSMS.txt', 'w', 'utf8') # Apre il file in codifica UTF8
for i in msg:
	f.write(box.address(i))
	f.write('\n')
	f.write(ctime(box.time(i))) # Converte i secondi in una stringa rappresentante il tempo
	f.write('\n')
	f.write(box.content(i))
	f.write('\n')
f.close()

print 'Fine'

f = codecs.open('E:/Others/listSMS.txt', 'r', 'utf8')
print f.read()
f.close()

Read SMS with inbox module

The new pys60 (1.3.1) provide 'inbox' module to read SMS.
It can also notify you when a new message arrives.
>>> import inbox
>>> i = inbox.Inbox()
>>> m = i.sms_messages()  # all message ID's
>>> i.content(m[0])     # first message
u’foobar’
>>> i.time(m[0])
1130267365.03125
>>> i.address(m[0])     # Only name is given :(
u’John Doe’
>>> i.delete(m[0])
>>>

I wish the i.address gave more detail information.
Currently, if you need the number, you need to search
the contact database.

See an example of notification callback in the documentation.
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS