email - AppleScript to attach photo to end of open Mail message -


in dec. 2012, mark hunte of stackoverflow site helped user providing following applescript. script creates new email msg. , attaches file end.

could here please me? need have shortened version of script 1 thing: attach file named "selectedphoto.jpg" end of already open email.

that is, if creating new email or replying email , have window open, run script attaches photo end of email.

i have tried taking out lines of following script, can't work.

i running os x 10.8

can help?


set theattachment1 posix file "/users/username/desktop/desktop--image/scooter-6.jpg"  tell application "mail"     set newmessage make new outgoing message properties {subject:"subject", content:"the_content" & return & return}     tell newmessage          set visible false         set sender "myaddress@btinternet.com"         make new recipient @ end of recipients properties {address:"someaddress@btinternet.com"}         make new attachment properties {file name:theattachment1} @ after last paragraph          (* change save send send*)         save --<<<<---------------- change save send send         (* change save send send*)     end tell end tell 

i couldn't tell outgoing message 1 make new attachment work, use ui scripting:

set old clipboard record set f "/library/desktop pictures/antelope canyon.jpg" set clipboard (read (posix file f alias) jpeg picture) activate application "mail" tell application "system events" keystroke "v" using command down set clipboard old 

Comments