PDA

View Full Version : Contents of mbox in Terminal?


levelbest
Nov 08, 2007, 05:13 AM
Hi folks, new to this site. I followed a Google hit to here where someone posted about terminal and mail. Hoping I might find some answers here, or perhaps someone can point me in a helpful direction?

I use a database, Panorama by Provue. If you are not familiar with it, pretty cool IMHO. Works in Ram and can run applescripts in its procedures and also can send and get data from terminal. I used Panorama to build my contact manager and my project manager.

I want to have each clients record in the Pan DB, do a quick lookup of my email correspondence with Mail. I envision a simple line or so of data for each message containing subject, date ID From or to, and perhaps 256 characters of the body.


This is going to look into specific named folders in Mail associated with each contact.

I envision clicking on any messages shown on that list to have it open in Mail. The last part is easily done with AppleScript, that is why I wan the message ID.

What I am asking is if there is a way to do this in the terminal? If I type: mdfind belinda.mbox,
I get a path to that persons mbx. What I want is a method to get whatever is in that mbox and parse it back into my panorama variable to show as a list with the data I mentioned, and be useable with AppleScript to find it again later by message ID. Panorama is quie powerful at manipulating data. Once I can figure how to get all the info I want located with the mbox I specify, I should be able to clean it up in panorama.

Of course simpler is usually better.

I am much better in Panorama than I am with AppleScript. AppleScript is certainly useful, but it also feels a bit slow when parsing lots of messages. It also seems to meed to activate the program it is accessing. But when running the Pan procedure I just want to fill the client email form to see the history. I only want to open Mail when I click on a list value.

I am new here and I hoped I have not stumped the band with my request. Thanks for having the space to ask this.

grotsasha
Nov 08, 2007, 05:36 AM
As far as I know .mbox format used by Mail.app is proprietary, so no terminal utility command can parse it to find out what's inside. You're right, when you're using AppleScript - Mail.app should be launched, since it's actually Mail.app that is providing you this information. If Mail.app is quit - there's no possibility to get inside its proprietary message format otherwise. If you really need to do sofisticated operations with your mail like that - you can migrate your messages to a client that uses a more open format, which can also take command line arguments - Thunderbird for example.

levelbest
Nov 08, 2007, 09:42 AM
Curious. I have been searching hi and low and I stumbled across one terminal users suggestion that showed how to rebuild the index for mail via command line. IT is a SQL3 lite file, or something like that. As there is a recognized db under the hood and as I can already send sql3 commands to it, I just figured, well maybe.. Are you pretty sure it is untouchable? Durn if so.

I just migrated back over to mail this week. Was using Mailsmith. Left Eudora after they seemed uninterested in keeping it going. Sigh, Thunderbird, after adding the new Eudora co-development track, on my downloaded copy, has been stuck on a three colomn view, left to right. And I just hate that. Yes, the preferences say you can change to a two colomn over under view, mine wont.

Perhaps I should find a Thunderbird forum and get to know TB a little better? I returned to mail after nearly 2 years with mailsmith because mailsmith, while a joy to the techy out there (not to me) was abysmal at searching for messages. Glacial speeds for that. No smart folders. Mail is like greased lightning compared to Mailsmith.

So long as TB is at least as fast and as easy as Mail in searches and smart folders...

But my database and contact manager are what I use to run my life. Like Daylight, I want good mail to DB integration. I figured if the makers of Daylite could do it, so could I. (Daylite if you didn't know does import Mails messages into Daylit and searches them per client in Dayite.

I am trying to do the same thing without importing the whole Mail DB. Another option certainly but trying to simplify and keep mail as mail for now.

ADDED:

OK, found a way to do this. Using MDfind I can search for any instance of an email address to or from a specific client. I have that array taken into my database and I can open any of those files again from the DB.

mdfind "kMDItemAuthorEmailAddresses = testaddress@yahoo.com || kMDItemRecipientEmailAddresses = testaddress@yahoo.com"

I can also take any of the found files and do MDLS on them and get the only really useful metadata I want to see one at a time, the subject, if it is from me or from them and the date. I still don't know if I can append the subject, date, etc to each found string though.I really have to figure that out for this to work. Otherwise I have all the emails for a client, but only shown as long strings to them on my HD. I need the subjects, dates, etc too.

Of course this is all metadata and I still am not able to get into the actual message files.

May not need to though. If I can just figure a way to parse the data I mentioned to each found element, I will be golden.