I've made some slight changes, so you can now easily provide the folder path as an argument (where the juno file is in), thus if you save the code in a file as e.g. juno_mail_extractor.py, you can run it like this
or if you make it executable, just
python ./juno_mail_extractor.py path_to_folder
(or just ./juno_mail_extractor path_to_folder if you remove the .py extension altogether)
You probably need to download the OleFileIO_PL module from here. You don't need to install it, but you can extract it and then just place your juno_mail_extractor.py file in the same folder as the module files and call it from there.
# -*- coding: utf-8 -*-
Created on Sat May 28 09:53:24 2011
from collections import defaultdict
if len(sys.argv) == 1:
print >> sys.stderr, "You need to provide the paths to the folder"
filename = os.path.expanduser(sys.argv)
source = OleFileIO_PL.OleFileIO(filename + '.frm')
messages = defaultdict(dict)
for file in source.listdir():
if len(file) == 2: # Messages, not 'Directory'
msg_num = int(file)
msg_type = file
stream = source.openstream(file).readlines()
def dict_to_mbox(messages, filename):
destination = mailbox.mbox(filename + '.mbox')
for msg_num, streams in messages.iteritems():
content = streams['Header'] + streams['Body']
content = ''.join(content)
message = mailbox.mboxMessage(content)
messages = frm_to_dict(filename)
print "Operation completed, and it was probably successfull"
Hope that helps.
EDIT: sorry I meant the folder path, not the file path..