Skip to content

Instantly share code, notes, and snippets.

@hepcat72
hepcat72 / sendText.osa
Last active September 24, 2024 03:06
Send SMS or iMessages via AppleScript
#!/usr/bin/env osascript
-- Version 2, now with attachments!
-- Note, the first couple times you run this script, the Messages app may prompt you to approve a couple things, one of which will be the ability to send SMS messages through your phone
-- Run via osascript on the command line like this:
-- osascript sendText.scpt --to ########## "this is" "a text message" --attachment "/path/to/image.png" "sent via applescript"
-- Where ########## is the phone number to send to
-- If you leave out `--to ##########`, it defaults to the value of an environment variable named MYPHONE in your .bashrc file (add the line "export MYPHONE=##########" to ~/.bashrc, entering your default phone number in place of ##########)
-- The 3 quoted strings will appear on separate lines and the image will be inserted between the lines "a text message" and "sent via applescript"
on run argv