Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript to send new iMessage

Hey guys - I'm trying to create an apple script to send a new iMessage. But I'm stuck. Can anybody help?


tell application "System Events"

tell application "Messages" to activate

tell process "Messages"

click menu item "New Message" of menu "file" of menu bar 1

end tell

...

endtell


... and thats it. How Do I tell Messages to fill in an email adress or phone number now and to send it?


Thank you!

Mac Pro (Early 2008), OS X Mountain Lion (10.8.2)

Posted on Sep 21, 2012 3:05 AM

Reply
Question marked as Best reply

Posted on Oct 11, 2012 1:42 PM

for me this is working very well .. on all my macs with different accounts(apple-IDs), and without manually handling the ID


tell application "Messages"

set myid to get id of first service

set theBuddy to buddy "+15555555555" of service id myid

send "Hi there" to theBuddy

end tell

22 replies

Apr 14, 2015 7:37 AM in response to Camelot

This is what I'm using and it works great! But I need some help to try something a little different.

tell application "Messages"

set theBuddy to buddy "+19525551212" of service "SMS"

send "Hi there" totheBuddy

end tell

Instead of "Hi there", I would like the script to look into a text document or an excel document or within the apple script and randomly pick a provided sentence. We can use the following sentences for example:

I love you.

Hope you have a good day.

Good morning.

AppleScript to send new iMessage

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.