[plug] print contents list of mbox folder [SOLVED]

Gavin Chester sales at ecosolutions.com.au
Mon Sep 18 18:09:35 WST 2006


On Mon, 2006-09-18 at 15:00 +0800, Bernd Felsche wrote:
> Russell <russellsteicke at gmail.com> writes:
> >On 9/17/06, Gavin Chester <sales at ecosolutions.com.au> wrote:
> 
> >> Can't find _anywhere_ instruction on how I can print (hardcopy or
> >> to a formatted file) the list of emails in a folder such as
> >> /inbox/plug/ that is in (evolution) mbox format.  That is, I want
> >> to print out the email list with just the 'from', 'to', 'subject'
> >> being almost all that shows such that the output resembles what
> >> you see when looking at the list of email in your email client.
> 
> >Trivial mbox parsing is easy.  Handling all the corner cases is hard.
> >Continuation lines (header lines starting with white space continue
> >the previous line) and slightly different From_ line formats are the
> >most obvious.  And I think that header field names are case-folded,
> >although almost everything uses "From" and "To" instead of "from" and
> >"to".
> 
> >Here's a trivial awk script that ignores most of those cases:
> 
> >#!/usr/bin/awk -f
> >BEGIN { Inheaders=0; }
> >/^From / { Inheaders=1; }
> >/^(To|From|Subject):/ { if (Inheaders) { print $0; } }
> >/^$/ { if (Inheaders) { Inheaders=0; print ""; } }
> 
> Python has some handy modules for that sort of thing.
> 
> This should get you started; there are examples in the Python
> documentation that you may not have installed in
> /usr/share/doc/packages/python/Demo/
> e.g. scripts/mboxconvert.py
> 
> Modules email and mailbox are quite useful.
> (module rfc822 has been superseded by email)
> 
> http://docs.python.org/lib/module-mailbox.html
> http://docs.python.org/lib/module-email.html

Thanks to both Russell and Bernd for your helpful suggestions.  I am
'just' a serious desktop user, and had neither the time nor the
knowledge to implement the sort of programming or scripting suggestions
you offered.  In my search over the past couple of days, I looked at
several useful tools but in the end I found just what I wanted was
offered by the mail archiving app 'Hypermail' (and I already had it
installed).  In the end, it was a question of defining better what I was
wanting to achieve then I realised hypermail fitted the bill very
well.   

Thanks to those who sacrificed brain energy in the pursuit of this
solution ;-)

Gavin 

-- 
Regards, Gavin Chester 
(Principal, BSc.Hons, Environmental Science)

ecosolutions(R) (est. 1990)
"... for all your environmental monitoring needs"
 PO Box 62, Dwellingup WA  6213
Tel: +61 8 95381102  Fax: +61 8 95381409




More information about the plug mailing list