How to script mails in mbox mailboxes

Hi

Can anyone give me a tip or hint how to script mails in folders like

/Volumes/import_xyz.mbox/abc_OUT.mbox

I’d like to get subject and sender to have an overview what’s in those folders. The folders were created by ‘emlx to mbox converter.app’ after a system crash.

Thanks in advance
Lazy

Hello.

The net should literally be spammed with snippets with sed, awk, and grep that extracts that information from mbox mail for you.

I’ll see if I can cook up something for you as well. For certain accounts, that doesn’t recieve rich text, this could still be something. For other purposes as well, like examining the full mail headers easily.

Could you please provide a link to that app?

here is a litte script, that you can use from the terminal first, later in a do shell script if you like:

You must change it to an executable (chmod u+x) and you use it like this : mailheading.sed <mbox

#!/usr/bin/sed -nf 1,$ { /Subject:/ { s/\(Subject:.*\)/\1/p } /From:/ { s/\(From:.*\)/\1/p } }
Edit:
if you have a lot of mbox files, spread over several folders and just not one big one then you can call it like this:

 for i in `find . -type d -depth 1` ; do for a in $i/* ; do echo $i/$a; mailheading.sed <$i/$a; done; done

Edit

I have edited slightly, since I didn’t take into account that the mbox-files would be in subfolders of where the one liner is to be executed from.

Just read each one and parse them for the data you want. For example:

set M to read alias "Macintosh HD:Users:bell:Library:Mail:Mailboxes:Kids.mbox:Messages:144349.emlx"
-- now extract what you want
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "From:"
set tParts to text item 2 of M
set AppleScript's text item delimiters to "Subject:"
set tSender to text item 1 of tParts
set tRest to text item 2 of tParts
set AppleScript's text item delimiters to "To:"
set tSubject to text item 1 of tRest
set AppleScript's text item delimiters to tid

For this example, tSender is the sender and tSubject is the Subject

Hi all

Thanks for the feedback.

Lazy