At 11:44 am -0600 16/1/04, Paul R Brown wrote:
I would like to be able to use bogofilter directly from within Mail.app for a number of reasons, and because AppleScript doesn't have a concept of pipes (do shell script can't handle input over 64kb), I'd like to find a solution to run a call-back from the command line of the form:
program a1 a2 a3 | bogofilter -Ns
where program is asking Mail.app for the raw source of the message from account a1, mailbox a2, and with message id a3. This would then be called from AppleScript with do shell script.
Possible with perl and Mac::?? Needs AppleEvents and I'm better off with C? Where do I start?
I pity anyone using Mail.app and even more anyone trying to use their completely mad and very buggy AppleScript support. The whole thing is detestable. At the moment I see it is not possible to get the 'content' of a message -- this has been possible on and off, mainly off, through the very uncertain development of this abortion, so one way to do what you want would be as below.
The quickest way would be to have a precompiled helper applet running and simplt send the data to a handler in the stay-open applet. I'm working on a sort of daemon at the moment which makes getting the results from an AS script quite fast -- many times faster than any other method -- but it's still at an early stage. The process is as follows : a) You write the AS script text to fin; b) you send the command `open -a the_applet fin`. c) the applet reads fin, runs the script and prints the result to fout. The Perl script waits for a semaphore that fout is printed and gets the result. When I have developed it a little further I'll make it available for people to try out.
my $message_index = 27;
my $mailbox = "Inbox";
my $account = "[EMAIL PROTECTED]";
my $ass = <<EOS;
tell application "Mail"
set _source to source of (message $message_index of�
mailbox "$mailbox" of account "$account")
end tell
return _source
EOS
$asresult = `osascript -e '$ass'`;
print $asresult;