I18N-Conflict: Is there a way to make OSX-Mail auto-strip redundant AW: and WG:

0

1

Microsoft managed to break their german translation of the mail programs, which results in subject lines like "AW: AW: AW: AW: AW: Question" when a mail is going back-and-forth and noone pays attention to the subject line. I believe the english version uses RE:, but strips it automatically.

I noticed OSX Mail.app is rather smart and removes multiple RE:, but it completely ignores the german version.

Is there a small setting/tool/plugin anywhere to make Mail.app recognize these too?

brandstaetter

Posted 2009-10-13T08:44:13.447

Reputation: 4 119

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

Answers

1

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!

Arjan

Posted 2009-10-13T08:44:13.447

Reputation: 29 084

...even changing the .emlx file on the file system does not change the displayed subject right away. When closing and re-opening Mail's window it will change the Subject as shown above the message, but the Subject as shown in the message list is only changed when rebuilding the mailbox. Too bad, I guess a combination of Rules and AppleScript is not the way to do this -- unless things are different when a message is in the process of being received... – Arjan – 2009-10-27T17:26:51.647

Ah, maybe after changing the .emlx file, all that's needed is (programmatically) move the message from one mailbox to another, and back. That's the easy part then! ;-) – Arjan – 2009-10-28T07:49:23.987

Thanks for the input. If I have too much time on my hands (probably never) I'll take a closer look at that. Too bad that this annoyance will probably never be really fixed. – brandstaetter – 2009-10-29T12:29:36.750

Amai, I should have asked not to give me that bounty... Now I might feel obliged to try some more ;-) (I actually might want to change the subject based on the headers some spam filters add, so I might come back...) – Arjan – 2009-10-29T12:32:01.413