Re: Modifying incoming mail subject
Re: Modifying incoming mail subject
- Subject: Re: Modifying incoming mail subject
- From: has <email@hidden>
- Date: Wed, 26 Dec 2007 23:30:37 +0000
On 26 Dec 2007, at 12:50, Michaël Grünewald wrote:
Using Mail app, I am trying to create an Applescript rule that do
modify incoming mail subject line. (I want to remove some fixed
input in mailing added by a mail manager.)
I have written the following applescript, save in a file and added
as a rule. It does not work (not any symptom of activity). As I am
new to applescript, I am looking for help to make it work.
Tip: always ensure local variable names are different to application-
defined keywords; syntax highlighting should help you tell the
difference. Try:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with each in theMessages
set subject_ to subject of each
set text item delimiters to "[Caml-list] "
set answer to ""
repeat with part in text items of subject_
set answer to answer & part
end repeat
set subject of each to (answer)
end repeat
end tell
end perform mail action with messages
end using terms from
1. If it is possible to plug a Unix filter in incoming mail's pipe,
that will also work for me!
The only documented plug-in API in Mail is the 'perform mail action'
event. (There's also an undocumented ObjC plug-in API that various
third-party developers like to play with.)
2. Having an honest Unix background, I would be very pleased to
recycle my comptentences with MAC OS X software. My first
impressions with MAC OS X is that the Unix side (shell + pipes) and
the Apple side (app + applescript) that do coexist in MAC OS X are
very alien one to the other. Are there some bridges between these
two worlds or are my first impressions somewhat right?
Somewhat right. The two environments evolved independently and mostly
live side-by-side. Desktop IPC is based on serialised message passing
[1] between event-driven processes.
As far as bridges go, AppleScript integration is not great: see
osascript for shell-to-AppleScript, and 'do shell script' for
AppleScript-to-shell, although you'll find them rather lacking. There
should be a couple of basic OSA language components for sh kicking
around somewhere, but without integrated Apple event IPC support their
usefulness will be extremely limited [2]. Your best bet may be Python
or Ruby, which can live fairly comfortably in both worlds and come
with plenty of Unixy goodness already included. The best Apple event
bridge currently available for those languages is appscript. It
requires separate installation, but this is pretty straightforward.
See my sig. for links. (There are other options as well, although
they're not as good.) OSA component support (needed for things like
Mail rules) is still rather limited, unfortunately, although a new
developer release of PyOSA will be out shortly which should be
reasonably usable with a bit of care.
HTH
has
[1] Think "XPath queries over XML-RPC" as a very rough analogy.
[2] If any shell heads feel like remedying this, objc-appscript is
approaching the point where it can be used to develop Apple event
bridges for other languages. While I don't have any near-term plans
for implementing an sh-appscript bridge myself, I'd be happy to
discuss ideas with anyone else that fancies having a go.
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
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