Applescript for Mail Not Working Since Upgrade to El Capitan

I have an Applescript to forward emails to Evernote that has stopped working since I upgraded to El Capitan. It opens the new message but does not update the email address or subject and does not send. Again, this worked prior to upgrading to El Capitan. Any help is much appreciated.



set theAddress to "email@evernote.com"

display dialog "Doc Name" default answer ""

set DocName to text returned of result


display dialog "Tags" default answer ""

set Tags to text returned of result


try

tell application "Mail"

set theSelection to selection

if DocName = "" then

set thesubject to subject of item 1 of theSelection & " " & Tags

else

set thesubject to DocName & " " & Tags

end if

set theForwardedMessage to forward (item 1 of theSelection) with opening window


tell theForwardedMessage


makenewto recipientat end of to recipientswith properties {address:theAddress}

set subject to thesubject

end tell


activate



delay 1


sendtheForwardedMessage

end tell


end try

OS X El Capitan (10.11)

Posted on Oct 18, 2015 3:23 PM

Reply
3 replies

Oct 18, 2015 10:55 PM in response to slotguru

Well, the first problem is that recipient lists no longer need (or, indeed, work) with the '... at end of...' specifier, so you can just:



makenewto recipientwith properties {address:theAddress}

The second problem, though, appears to be a bug. Even with a valid recipient list the script fails on the line:

set subject to thesubject

Which, as far as I can tell, is a bug - you can't change the subject of a forwarded message. It's fine if you create a new message, and if you manually forward a message you can change the subject, but you can't change it via AppleScript.


The best I could come up with is a tacky UI scripting 'solution':


tell theForwardedMessage


makenewto recipientwith properties {address:theAddress}

end tell


activate

tell application "System Events"


keystroketabusingshift down


keystrokethesubject

end tell


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript for Mail Not Working Since Upgrade to El Capitan

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.