How to send a Text Message with AppleScript

Lets say you have this awesome AppleScript that pulls the data that you want from one of our previous tutorials like How to Extract Information From a Webpage Using AppleSript. What do you do with the data now? You could save the info to an Excel doc… or you could send it to yourself or your team via iMessage!

The first thing that you have to do is open iMessage and message the number that you want to send the text message to. iMessage needs to have previously sent a message to the number before the following code will work.

Next enter the following code into your AppleScript:

tell application "Messages"

set iMessageid to get id of first service

set theNumber to buddy "+1yournumber" of service id myid --enter the number that you want to send your message to here

send "CubeMG just made my life 10x easier!" to theNumber

end tell

One note for this… if you are using a work computer this may not work. You need to have your personal credentials in iMessage, like your iCloud username.

If you want to schedule your AppleScript to run on a daily basis you can set an alarm in your iCal to run the send message AppleScript… The only drawback to this is that your computer must be on.

If you have any questions feel free to leave a comment or reach out through our contact form.

Samuel

4 Responses to “How to send a Text Message with AppleScript

  • I RAN THE SCRIPT AND GOT THIS ERROR. WHAT AM I DOING WRONG.

    error “The variable myid is not defined.” number -2753 from “myid”

  • I RAN THE SCRIPT AND GOT THIS ERROR. WHAT AM I DOING WRONG.

    error “The variable myid is not defined.” number -2753 from “myid”

  • WHEN I REPLACE “iMessageid” WITH THE WORDS “MYID” YOUR SCRIPT WORKS. IF I LEAVE IT THE WAY YOU HAVE IT I GET AN ERROR.

    ERROR “THE VARIABLE MYID IS NOT DEFINED.” NUMBER -2753 FROM “MYID”

  • WHEN I REPLACE “iMessageid” WITH THE WORDS “MYID” YOUR SCRIPT WORKS. IF I LEAVE IT THE WAY YOU HAVE IT I GET AN ERROR.

    ERROR “THE VARIABLE MYID IS NOT DEFINED.” NUMBER -2753 FROM “MYID”

Leave a Reply Text

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.