andrewlausanne

Q: Need applescript for Messages to send Passbook .pkpass attachments

Hi - I'm trying to write an applescript to send iMessages to a list of recipient Phone numbers with Passbook .pkpass files as attachments.

 

Here's my simple sendMessage.applescript file

 

on run {targetBuddyPhone, targetMessage, targetFile}

          tell application "Messages"

                    set targetService to 1st service whose service type = iMessage

                    set targetBuddy to buddy targetBuddyPhone of targetService

  send targetMessage to targetBuddy

  send file targetFile to targetBuddy

          end tell

end run

 

I'm calling this from Terminal with command:

 

osascript sendMessage.applescript <Phonenumber> "Here's your Passbook coupon" Coupon.pkpass

 

When I execute the command, my targetMessage is correctly sent. However, the .pkpass file transfer says it is waiting for the recipient to accept the file transfer.

When I send it to my own iPhone, I don't receive any request to accept a file transfer.

 

How can I modify this script such that the file is properly attached to the iMessage and it sends with an auto-accept condition ?

 

Thanks if you can help,

Andrew

Mac mini, OS X Mountain Lion (10.8.3)

Posted on Nov 2, 2013 2:58 PM

Close

Q: Need applescript for Messages to send Passbook .pkpass attachments

  • All replies
  • Helpful answers

  • by JaccobK,

    JaccobK JaccobK Jun 4, 2016 5:11 AM in response to andrewlausanne
    Level 1 (8 points)
    Jun 4, 2016 5:11 AM in response to andrewlausanne

    This should help with the targetfile you are trying to send.


    set targetfile to POSIX file "/Users/Andrew/Desktop/EnergyUse.pdf"

    send targetFile to targetBuddy


    Don't need the word "file" in the send script. "send file targetFile to targetBuddy"


    Obviously set it to the path of your file. I'm showing an example of a PDF. When i was trying to find an example of attaching a file / picture some of the examples were incorrect.