Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 33 lines (26 sloc) 0.814 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/usr/bin/osascript

on run argv
  if argv is {} then
    return "Pass at least one filename as an argument!"
  end if

  set pwd to system attribute "PWD"

  tell application "Mail"
    try
      -- This only works for messages created by this script
      set composeMessage to first outgoing message where visible is true
    on error
      set composeMessage to make new outgoing message at beginning with properties {visible:true}
    end try

    tell composeMessage
      repeat with fileName in argv
        if not fileName starts with "/" then
          set fileName to pwd & "/" & fileName
        end if
        tell content
          make new attachment with properties {file name: fileName} at after the last paragraph
        end tell
      end repeat
    end tell

    activate

  end tell
end run
Something went wrong with that request. Please try again.