Send image from Messages.app to iMessage

Discussion in 'Mac Programming' started by MACza, Oct 19, 2012.

  1. macrumors member

    Joined:
    May 10, 2011
    #1
    Hi Guys!

    I hope somebody can assist me with an applescript I am attempting.

    The aim: to send myself an image from my MAC to my iphone via Messages/iMessage.

    OK, I can send text messages successfully with the following:

    Code:
    tell application "Messages"
    	set myid to get id of first service
    	set theBuddy to buddy "+123456789" of service id myid
    	send "Test message" to theBuddy
    end tell
    
    How do I now add an image to the message?

    I was trying something like the following:

    Code:
    tell application "Messages"
    	set myid to get id of first service
    	set theBuddy to buddy "+123456789" of service id myid
    	set targetFileName to "Macintosh HD:Users:user:Pictures:picture.PNG:"
    	make new attachment with properties {file:targetFileName}
    	send "Test message" to theBuddy
    end tell
    
    WIth the above, I get the following error back:
    "Messages got an error: Can’t make or move that element into that container."

    I am not sure what this means or what the solution is :confused:

    It also seems like I should tell Messages to send the attachment. Not sure if it should be part of the "send" command, or if I should send the image in it's own "send" call.

    Any help will be greatly appreciated! :D

    Thanks!
     
  2. thread starter macrumors member

    Joined:
    May 10, 2011
  3. macrumors newbie

    Joined:
    Nov 8, 2012
    #3
    Hi,

    Would you mind sharing how you sorted this out ? Trying to do the same thing.

    Thanks!

    Keith
     
  4. macrumors newbie

    Joined:
    Jan 20, 2013
    #4
    Hi,
    how did you fix the error? i am interested in doing the same thing.

    Thanks
     
  5. macrumors newbie

    Joined:
    Jan 30, 2013
    #5
    set theAttachment1 to POSIX file /Users/lil/pic.png
    tell application "Messages"
    send theAttachment1 to buddy "+1 (xxx) x7 " of service "E:yourappleid@gmail.com"
    end tell
     

Share This Page