By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,536 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,536 IT Pros & Developers. It's quick & easy.

parsing emails

P: n/a
I use Mozilla or Netscape, so my emails are stored in the nsmail
directory
or the Mozilla's equivalent. What's the simplest way to look at them
and
extract the mails with a given subject? In principle I could use a
regular expression, but I bet there are better solutions already
available.
Second question: are Mozilla and Netscape compatible, i.e. are the
emails stored with the same format and can I use the same extraction
method on both?

TIA,
Michele Simionato
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Michele Simionato" <mi***************@poste.it> wrote in message
news:95**************************@posting.google.c om...
I use Mozilla or Netscape, so my emails are stored in the nsmail
directory
or the Mozilla's equivalent. What's the simplest way to look at them
and
extract the mails with a given subject? In principle I could use a
regular expression, but I bet there are better solutions already
available.
Second question: are Mozilla and Netscape compatible, i.e. are the
emails stored with the same format and can I use the same extraction
method on both?

TIA,
Michele Simionato

Michele -

Python 2.3 introduced a new email package, that has an email.Parser module.
I've not used it myself, but it sounds worth looking into.

-- Paul
Jul 18 '05 #2

P: n/a
On Sat, 20 Mar 2004 00:29:40 -0800, Michele Simionato wrote:
I use Mozilla or Netscape, so my emails are stored in the nsmail
directory
or the Mozilla's equivalent. What's the simplest way to look at them
and
extract the mails with a given subject? In principle I could use a
regular expression, but I bet there are better solutions already
available.
Second question: are Mozilla and Netscape compatible, i.e. are the
emails stored with the same format and can I use the same extraction
method on both?

TIA,
Michele Simionato


Ciao Michele,
maybe you could use something like that

"""code not tested"""
import email
import mailbox

fp=file('fileName','r')
mbox = mailbox.UnixMailbox(fp, email.message_from_file)

msg_list=[]
for msg in mbox.next():
if msg['Subject']=="the subject you're searching for":
msg_list.append(msg)
fp.close()

for msg in msg_list:
print msg

Dunno about Mozilla/Netscape compatibility, but I think they'll use the
same mail format.

Ciao,
Riccardo

--
-=Riccardo Galli=-

_,e.
s~ ``
~@. ideralis Programs
.. ol
`**~ http://www.sideralis.net
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.