Created
October 15, 2013 01:30
-
-
Save masnick/6985205 to your computer and use it in GitHub Desktop.
Create an email message in Mail.app with this AppleScript. Callable from the Terminal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on replace(input, find, replacement) | |
set text item delimiters to find | |
set ti to text items of input | |
set text item delimiters to replacement | |
ti as text | |
end replace | |
--Variables | |
on run argv | |
set recipientName to item 1 of argv | |
set recipientAddress to item 2 of argv | |
set theSubject to item 3 of argv | |
set theContent to item 4 of argv | |
set theContent to replace(theContent, "\\n", return) | |
--Mail Tell Block | |
tell application "Mail" | |
--Create the message | |
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true} | |
--Set a recipient | |
tell theMessage | |
make new to recipient with properties {name:recipientName, address:recipientAddress} | |
--Send the Message | |
--send | |
save | |
close | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment