Hey Folks,
This is a working proof-of-concept.
It lets you test for anything that's available to AppleScript from the selected email - to, from, header-content, textual-content, etcetera - and then reply to a single address.
Script 2 shows how to reply-to a group. (I did this previously with a Contacts-Group abbreviation, but I figured out how to make Mail accept a comma-delimited list - similarly to when you paste such.)
Although you can change the account by accessing the pop-up account button with System Events, it's faster and smoother using keyboard shortcuts as I have in this script.
I am disappointed that Mail's reply command does not allow for replying with only the selection as you can do with the normal Cmd-R or menu based reply.
That seems like a no-brainer and is a surprising omission.
------------------------------------------------------------------------------------------- # Auth: Christopher Stone # dCre: 2015/10/05 11:32 # dMod: 2015/10/05 12:35 # Appl: Mail, System Events # Task: Reply with Rules # Libs: None # Osax: None # Tags: @Applescript, @Script, @Mail, @System_Events, @Reply, @Rule # Test: OSX 10.11 -------------------------------------------------------------------------------------------
set replyToAddress to missing value
tell application "Mail" set messageSelectionList to selection if messageSelectionList ≠ {} then set selectedMessage to item 1 of messageSelectionList
tell selectedMessage try set listIdHeader to content of first header whose name is "List-ID" on error set listIdHeader to missing value end try
repeat 1 times
if listIdHeader ≠ missing value then
--» Applescript Users List Rule set replyToAddress to "Applescript Users List < email@hidden>" set sendFromAccount to "l" set commandKeyList to {command down, control down} exit repeat end if
--» BBEdit-Talk Rule set sendFromAccount to "l" set commandKeyList to {command down, control down, shift down} exit repeat end if
end if
end repeat
end tell
set newOugoingMesssage to reply selectedMessage with opening window set bounds of front window to {407, 23, 1312, 1196}
else error "No messages selected!" end if
end tell
-----------------------------------------------------------------------------------------
if replyToAddress ≠ missing value then
tell application "System Events" tell application process "Mail" set frontmost to true tell (first window whose subrole is "AXStandardWindow") delay 0.05 keystroke sendFromAccount using commandKeyList -- keyboard shortcut for from in sys-prefs. tell text field "To:" to set its value to replyToAddress end tell end tell end tell
end if
-------------------------------------------------------------------------------------------
# Reply-To Multiple Recipients
-------------------------------------------------------------------------------------------
tell application "Mail" set messageSelectionList to selection if messageSelectionList ≠ {} then set selectedMessage to item 1 of messageSelectionList reply selectedMessage end if end tell
set {sendFromAccount, commandKeyList} to {"l", {command down, control down}}
tell application "System Events" tell application process "Mail" set frontmost to true tell (first window whose subrole is "AXStandardWindow") delay 0.05 tell text field "To:" set focused to true set its value to replyToAddress key code 36 end tell tell scroll area 1 to tell UI element 1 set focused to true end tell keystroke sendFromAccount using commandKeyList -- keyboard shortcut for from in sys-prefs. end tell end tell end tell
-------------------------------------------------------------------------------------------
|