The same in the Dutch Outlook: "Re: Betr.: Re: Doorgest.:" for "Re: Re: Re: Fw:" which should probably be just "Re:" then...
I am no AppleScript expert, but based on the samples in /Library/Scripts/Mail Scripts/Rule Actions, this might get you (or someone here at Super User) started. However, this is not at all a working solution, as I don't know how to make Mail persist the changes. The following will change the subject as shown in the message list, but not the same subject as shown above the message when viewing it. Even worse: restarting Mail gives one the old subject again.
I assume one needs to change the actual source of the message, not just the subject. And maybe AppleScript cannot even do that, but it felt like a waste of time not to post my tries here. ;-)
(EDIT: attempts to change the source
property of a message yield "Mail got an error: AppleEvent handler failed." number -10000
... Maybe the actual .emlx
file must be changed on the file system?)
For testing, it's easiest to create a script that runs for the currently selected message. Like: save the following in a text file named, for example, test-clean-subject.scp
and then double-click it to open AppleScript Editor. Then just click the Play button:
tell application "Mail"
set selectedMessages to selection
if (count of selectedMessages) is equal to 0 then
display alert "No Messages Selected" message ¬
"Select one or more messages before running this script."
else
repeat with theMessage in selectedMessages
-- Of course, handling just one prefix is NOT AT ALL sufficient:
set thePrefix to "Aw: "
set theNewSubject to subject of theMessage
repeat
if theNewSubject does not start with thePrefix then
exit repeat
end if
set theNewSubject to text ((length of thePrefix) + 1) ¬
through -1 of theNewSubject
end repeat
-- Testing only:
display dialog "New subject: " & theNewSubject
-- This only (temporarily) sets the Subject in the message list.
-- Maybe change "source" instead...?
set subject of theMessage to theNewSubject
end repeat
end if
end tell
You might need to click on the message list to actually see Mail changed it. Again: the above does not solve your problem yet! Also, when one figures out how to persist the changed subject, then the search and removal/replace needs to be much more sophisticated than just searching for a single "Aw: ".
For a true Mail Rule, things need to be slightly different. Copy the relevant parts from a working standalone script into the following, save it and then create a new Rule in Mail for each incoming message (or for messages for a specific sender):
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with theMessage in theMessages
-- copy the actual script here...
end repeat
end tell
end perform mail action with messages
end using terms from
See also Introduction to Scripting Mail at MacTech, and some examples of find and replace at MacScripter.
DISCLAIMER: none of the above has been tested a lot!
And what does this have to do with Outlook? – Ðаn – 2009-10-24T04:21:24.513
That the german version of Outlook is the one that has the (imho) broken translation and produces AW instead of RE. I want something for OS X Mail to work around that, since Microsoft clearly does not care about this and will probably never fix it. – brandstaetter – 2009-10-26T06:45:51.970