Re: getting headers from Mail
Re: getting headers from Mail
- Subject: Re: getting headers from Mail
- From: John Delacour <email@hidden>
- Date: Tue, 19 Nov 2002 04:57:51 +0000
- Mac-eudora-version: 5.3a9
At 2:43 pm -0500 18/11/02, Brian Redman wrote:
I'm using a pretty lame script to get headers and flags for messages in
a given mailbox from Mail. It's called periodically and takes about
1/4 second per message best case. The script iterates though the
messages:
...
sender of eachMessage
cc recipients of eachMessage
to recipients of eachMessage
date sent of eachMessage
subject of eachMessage
is junk mail of each eachMessage
is read of eachMessage
is deleted of eachMessage
...
Is there a more efficient way to use Applescript to send a slew of
commands to a program. For instance to get mail to spit out all the
headers and/or flags at once. For all the messages? I'd like to get at
some headers that aren't in the dictionary too. I'm guessing I'll need
to read the entire message?
I had code (not applescript) that read ~/Library/Mail/Mailboxes/... but
wanted to do it the "right" way if possible.
I'd say that IS the right way. Apple Events are very slow --
especially slow with Mail I guess, since the whole thing is as fast
as treacle. It takes ages even to open a window. Wish I could see it
running on an SE-30!
This script won't give you the last three properties, of course,
though you'd probably get these from parsing the toc. Sooner you
than me.
tell app "Mail" to set dir to account directory of account 1
set text item delimiters to {"@"}
set ls to text items of dir
set text item delimiters to {"\\@"}
set dir to "" & ls
set text item delimiters to {""}
do shell script "perl -e '
open MBOX, ($mbox = qq~" & dir & "/INBOX.mbox/mbox~) ;
for (<MBOX>) {
/^From .+\\@/ && ++$i && print qq~\\n--- Message $i ---\\n~ ;
/^From: |^To: |^Cc: |^Subject: |^Date: /i and print ; }'"
JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.