SHARE
TWEET

Untitled

a guest Jun 25th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set myReply to "Thanks, I've received your email. If I have any questions about it I will contact you directly"
  2.  
  3. tell application "Mail"
  4.     set theSelection to selection
  5.     if theSelection is {} then return
  6.     activate
  7.     repeat with thisMessage in theSelection
  8.         set theOutgoingMessage to reply thisMessage with opening window
  9.         repeat until exists (window 1 whose name = "Re: " & subject of thisMessage)
  10.         end repeat
  11.         delay 0.1
  12.  
  13.         -- send gui scripting to handler to get it out of Mail tell block
  14.         my guiScriptMail(myReply)
  15.         send theOutgoingMessage -- This automatically sends the message!
  16.     end repeat
  17. end tell
  18.  
  19. on guiScriptMail(myReply)
  20.     tell application "System Events"
  21.         tell process "Mail"
  22.             set frontmost to true
  23.             -- keystroke "a" using {command down} -- ⌘A to select all
  24.             keystroke myReply
  25.         end tell
  26.     end tell
  27. end guiScriptMail
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top