There was a recent post on the the Mac Rumors Forum with this AppleScript question:
“I have a rule in Mail, which moves specific emails to a specific email folder… Now I need an AppleScript to run in conjunction with the rule, which will save each email as a txt file in a folder on my desktop…. Can anyone suggest how I go about this?”
You remember that I whipped up an Export Apple Mail Messages to Text Files script just a few weeks ago that pretty much fits that description, right? So I thought that, in the process of turning it into something that Apple Mail can use, I could do a little walk-through for you guys of how to write a script like this in the first place!
Easy, right? A walk in the park.
HA! 😉 (And how does that Robert Burns poem go again?)
“Hmmph. That’s weird.”
After a short burst of hack-fu, I had a script that would work within Apple Mail…with one small caveat: When selecting the message and applying the rule manually, everything worked… But when a message arrived on my Exchange email account and triggered the script by a rule, it exported the content of the previous message to the resulting text file.
Hmmph. That’s weird. “I must have made a mistake somewhere…”, I said to myself.
But no matter what I tried, it always exported the wrong file! I called in the big guns for help with this post on the MacScripter website. Ben Waldie — a guru in AppleScript community and author of many excellent books about Automator— personally pitched in to try and sort this out…. sadly to no avail. (Thanks again, Ben!)
A quick search around reveals that this may not just be me: I saw this Comment Thread and also this post on stackoverflow.
Is this a wide-spread bug with Apple Mail, Exchange, and AppleScript? I’ve noticed a few other shall-we-say… anomalies with the way OS X works with Exchange — and I’m starting to wonder if this is another to add to the list.