Skip to content

Instantly share code, notes, and snippets.

@endolith
Created May 28, 2011 17:56
Show Gist options
  • Select an option

  • Save endolith/997075 to your computer and use it in GitHub Desktop.

Select an option

Save endolith/997075 to your computer and use it in GitHub Desktop.
Convert Juno 4 OLE messages to MBOX format

Juno 4 uses .FRM files to store emails, which are OLE format

This script uses OleFileIO_PL to extract the messages and writes them to mbox format so they can be imported into other software.

It converts \r\n to \r\r\n, which is probably wrong. I just replaced those manually in Notepad++ afterwards.

The files are in mboxo format, so a line starting with >from is ambiguous. Thunderbird opens them in mboxrd format, which interprets these as from . These can also be fixed manually by hand, if you care, by searching for \n>from and replacing it by \n>>from , replacing \n>>from with \n>>>from , etc.

# -*- coding: utf-8 -*-
"""
Created on Sat May 28 09:53:24 2011
@author: [email protected]
"""
import mailbox
import OleFileIO_PL
from collections import defaultdict
filename = "FOLD0001"
def frm_to_dict(filename):
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[0])
msg_type = file[1]
stream = source.openstream(file).readlines()
messages[msg_num].update({msg_type: stream})
return messages
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)
destination.add(message)
destination.close()
messages = frm_to_dict(filename)
dict_to_mbox(messages, filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment