• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
El Capitan Mail - Rule-Based Reply
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

El Capitan Mail - Rule-Based Reply


  • Subject: El Capitan Mail - Rule-Based Reply
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 05 Oct 2015 13:12:02 -0500

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.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# 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
          if listIdHeader contains "applescript-users.lists.apple.com" then
            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
          if listIdHeader contains "bbedit.googlegroups.com" then
            set replyToAddress to "BBEdit-Talk <email@hidden>"
            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 replyToAddress to "Robert Heinlein <email@hidden>, Larry Niven <email@hidden>"
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

-------------------------------------------------------------------------------------------


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
  • Next by Date: Re: XML-RPC
  • Previous by thread: Re: El Capitan
  • Next by thread: Cannot Write to Combo Box with System Events
  • Index(es):
    • Date
    • Thread