Can somebody show me how to send a message directly to the user of iMessage via Messages app?
tell application "Messages"
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 2
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 3
send "Message" to buddy "mail of name" of service x
end tell
I need to send a message to an account only via iMessage, not via google talk, AIM, bonjour. Thank you!
Instead of having to hard-code the iMessage service, you can find it automatically:
sendMessage.applescript
(Note: make sure to choose the Text option).osascript sendMessage.applescript 1235551234 "Hello there!"
.sendMessage.applescript:
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run