Re: Mailboxes in Mail & Applescript
Re: Mailboxes in Mail & Applescript
- Subject: Re: Mailboxes in Mail & Applescript
- From: Christopher Stone <email@hidden>
- Date: Sat, 28 Apr 2012 06:10:48 -0500
On Apr 28, 2012, at 01:38, John Mitchell wrote: thanks for that suggestion; I used it to work out a satisfactory solution as follows:
______________________________________________________________________
Hey John,
If I was following the thread correctly you wanted to get only the top-level mailboxes in On My Mac.
Your script doesn't work properly on my machine for some reason, and I haven't yet taken time to figure out why.
On Snow Leopard it used to be possible to coerce mailboxes into their path-strings, but I don't seem to be able to do this on Lion — thus the somewhat ugly hack. It works on my machine and is pretty quick.
------------------------------------------------------------------------------------------------ on forcedError(m) try m / 1 on error e return quoted form of e end try end forcedError ------------------------------------------------------------------------------------------------ tell application "Mail" set m to mailboxes set e to forcedError(m) of me set e to do shell script "echo " & e & " | perl -0777 -ne 's/«class mact»|«class mbxp»/\\n/g; print' \\ | perl -0777 -ne 's/\\A.+\\s+//; print' \\ | perl -0777 -ne 's/}.+\\s+\\Z//; print' \\ | sed -E 's/ ?\" ?//g' | sed -nE '/\\//p' | sed -E 's:^([^/]+)/.*: \\1:' | sort -u" set AppleScript's text item delimiters to return set e to text items of e repeat with i in e set subj to subject of messages of mailbox i if length of subj > 0 then exit repeat end repeat subj end tell ------------------------------------------------------------------------------------------------
I know there's a nice way to blend the Perl together, but I don't know how to do it yet.
-- Best Regards, Chris
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden