Help with attaching image to messages in AppleScript

Discussion in 'Mac Programming' started by Pegoto, Dec 24, 2013.

  1. Pegoto macrumors newbie

    Joined:
    Jun 7, 2011
    #1
    Hi, i am trying to send an image via messages using applescript and I get the error "Messages got an error: Can't send specified file." Everything else works fine, it is just send the image. This is what I have in my AppleScript:

    Code:
    do shell script "curl -f 'http://<IP_OF_CAMERA/snapshot.cgi?user=<USERNAME>&pwd=<PASSWORD>&resolution=32' -o ~/Desktop/test.png"
    tell application "Messages"
    	send "Garage door has been opened." to buddy "<iMESSAGE_RECIPIENT.com>"
    end tell
    set theAttachment1 to POSIX file "Desktop/test.png"
    tell application "Messages"
    	send theAttachment1 to buddy "<iMESSAGE_RECIPIENT.com>"
    end tell
    I am an AppleScript noob and I have been able to piece this together from various posts on here and elsewhere.
     
  2. Pegoto, Dec 24, 2013
    Last edited: Dec 24, 2013

    Pegoto thread starter macrumors newbie

    Joined:
    Jun 7, 2011
  3. Pegoto thread starter macrumors newbie

    Joined:
    Jun 7, 2011
    #3
    Got it all working. Leaving it up for someone else that might need it or when I forgot how I did it and have to recreate it because my backup was corrupt ;)

    Code:
    do shell script "curl -f 'http://<IP_OF_CAMERA/snapshot.cgi?user=<USERNAME>&pwd=<PASSWORD>&resolution=32' -o ~/Desktop/test.png"
    tell application "Messages"
    	send "Garage door has been opened." to buddy "<iMESSAGE_RECIPIENT.com>"
    end tell
    set theAttachment1 to POSIX file "Desktop/test.png"
    tell application "Messages"
    	send file theAttachment1 to buddy "<iMESSAGE_RECIPIENT.com>"
    end tell
     

Share This Page