Hello to all.
I’ve only lightly dabbled in AppleScript in the past and am currently trying to create a couple of seemingly simple scripts to redirect a selected message (or multiple messages, if possible) to a pre-set e-mail address. I’m using apple Mail in MacOS Sierra 10.2.2.
I’ve looked in the scripting dictionary and tried using the redirect command as well as the mailto, but I never get past two lines before the compiler tells me I’m on the wrong track.
I thought the structure would look something like this:
tell application Mail
redirect selected message
mailto email@emailadress.com
end tell
Obviously, this didn’t sit well with Script Editor.
Ideally, I’d like to have the scripts just sit in AppleScript menubar menu ready to select and automatically redirect the selected message to an address written into the script.
set destAddress to "email@emailadress.com" # Edit to fit your needs
tell application "Mail"
activate
set theMessages to the selection # one or several message(s) selected
repeat with aMessage in theMessages
set newMessage to redirect aMessage
tell newMessage
make new to recipient with properties {address:destAddress}
end tell
send newMessage
end repeat
end tell
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mardi 10 janvier 2017 10:19:03
Yvan,
THANKS! Your script worked great. I truly appreciate your help. Looking at the script it became painfully obvious that it would have taken me possibly a decade of research to arrive at that language. Your command of AppleScript is impressive.
set destAddress to "email@emailadress.com" # Edit to fit your needs
tell application "Mail"
activate
repeat with aMessage in (get the selection)
tell (redirect aMessage)
make new to recipient with properties {address:destAddress}
send it
end tell
end repeat
end tell
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mardi 10 janvier 2017 18:18:54
Hi again, Yvan and everyone.
I’m suddenly having an odd issue… I just updated to MacOS Sierra 10.12.3, and when I invoke the wonderful script you authored, Mail hangs. The spinning beach ball appears and my only recourse is to force quit and relaunch. Manually forwarding works, but the AppleScript results in the freeze.
I feel foolish for updating so quickly, but didn’t imagine there would be issues with Apple’s own software. Has anyone seen any issues with AS and the new update?
Here the script behaves flawlessly as it did before with 10.12.2 and the 10.12.3 beta versions.
At first look there is nothing in com.apple.mail.plist able to fool the app but it costs nothing to try to drop it :
quit Mail
drag & drop the named preferences file onto the desktop
restart the app.
If it’s inefficient you may try to repair permissions.
I know that the feature is no longer available in Disk Utility but it’s available in the free Onyx.
Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mardi 24 janvier 2017 09:25:54
Hi, Yvan.
Thanks for the fast reply! After I posted, It occurred to me to try a permissions repair. First I cleared PRAM and then used Onyx (I usually use Sierra Cache Cleaner, but, of course, the new OS update isn’t yet compatible) and so far, so good! If the issue reappears, I’ll try removing the plist file and see if that helps.