AppleScript Forward Messages Attachments

Hello,

I'm new to AppleScript but learned a bit from searching online. Basically I would like to forward iMessage messages to an e-mail address. I did this with the following script:


using terms from application "Messages"

on message received theMessage from theBuddy for theChat


tell application "Mail"

set theNewMessage to make new outgoing message with properties {subject:"thesubject", content:theMessage, visible:true}

tell theNewMessage

make new to recipient at end of to recipients with properties {address:"myemail@gmail.com"}

send

end tell

end tell


end message received

end using terms from


Works great and it puts the iMessage in the content of an e-mail that gets sent to me.


Now I'm trying to do this with attachments as well. I modified the code to give me 4 beeps when a file is received but nothing happens. Any help would be appreciated I've searched google for hours and I'm kind of at a dead end.


Modified Code:


using terms from application "Messages"

on message received theMessage from theBuddy for theChat


tell application "Mail"

set theNewMessage to make new outgoing message with properties {subject:"thesubject", content:theMessage, visible:true}

tell theNewMessage

make new to recipient at end of to recipients with properties {address:"myemail@gmail.com"}

send

end tell

end tell


end message received

on completed file transfer theFile

beep 4


end completed file transfer

end using terms from

iPhone 4S, iOS 5.0.1, Win 7 64bit

Posted on Aug 3, 2013 11:00 PM

Reply
20 replies

Aug 12, 2013 1:37 PM in response to Nikokon

HI,


The Auto Accept and the separate Auto Decline Scripts were included with Apple's iChat.


The Mountain Lion Upgrade moves them from Hard Drive/Library/Scripts/iChat to the Messages folder.

It also changes the "Using terms from application "iChat" " to reading "Messages" (i.e.Scripts seems to exist in Mountain Lion even if you did fresh Install)


As with several of the Apple included Scripts they are written in such a way that can be applied to several scenarios. (It depends which Action/Alert you link them to in the Alerts Prefs).

The Auto Accept could accept Text Chats, Video Invitations and Audio Only Chat Invitation and File Transfers.


The Auto Decline one is similar in that it can be set to Receiving Messages (or Invites)< Video and Audio Invites and File Transfers but decline them.


It must be remembered that these scripts were written when iChat actually popped up a Text Chat Invite window before the Chat window was shown (the same way Video and Audio Invites and File Transfers not linked to a Chat appear).


It seems that Messages Auto Accepts Chats (or iMessages) anyway and puts them on display in the tabbed chat Messages window.



User uploaded file
9:37 PM Monday; August 12, 2013


 iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
 G4/1GhzDual MDD (Leopard 10.5.8)
 MacBookPro 2Gb (Snow Leopard 10.6.8)
 Mac OS X (10.6.8),
 Couple of iPhones and an iPad
"Limit the Logs to the Bits above Binary Images."  No, Seriously

Mar 14, 2014 9:21 PM in response to Nikokon

Would this work to have iMessages forward to an AIM account?


I recently broke my iPhone and have resorted to using my first gen iPod touch which only runs iOS 3.1.3 which means it doesn't run iMessage, which is the main way my family communicates. I've been able to use aim to text most people, but I haven't found a way to replace iMessage. I would love to be able to use this method, but i need a little help if it's possible. I'm also running Mavericks, so it may not be possible.

Mar 15, 2014 2:36 PM in response to RadicalxEdward

Hi,


The Messages app on the Mac does have the ability to add all those different forms of accounts for the different services.


Some like logging in at AIM allow you to add "Google Buddies" and "Facebook Buddies" and both of those Jabber services offer the chance to add AIM Buddies to their Buddy list when logged in via a web browser.


In Messages you cannot add Jabber Buddies to an AIM Buddy list.


There is a round about way to get Yahoo or MSN or AIM Buddies into a Jabber Buddy List

See http://allforces.com/2005/05/06/ichat-to-msn-through-jabber/


Basically you find a Jabber server that is running what are called Transports or Gateways.

You then link your AIM Account to that Jabber Buddy List and add Buddies by adding the Jabber Transport's name to their Screen Name and removing the extra @ and replace it with a % symbol.


You can then do the same for MSN, Yahoo and other services.


If you pick the "right" new Jabber server you can access the Transport server whilst adding the Buddies to another Jabber Buddy list.

In the Instructions the Buddy is example as:-


msn account name:
sireltonjohny@hotmail.com


jabber address format
sireltonjohny%hotmail.com@msn.netlab.cz


Once you have this Buddy Name you can add it to a Google Buddy list if you wanted.


Having said that I have not heard of an App or a Transport to do this for the iMessages servers.


Having said that AppleScript might be an option.


Back in August yongjunj posted a link which has a further link to here

From my understanding the bit that forwards the iMessage would need to also list "the Service" as well as the The Buddy and The Text so that you could change it to AIM.


There are also some semantic cross overs to avoid or get your head around.

In the published info by Apple iChat deals with Buddies and Chats but info on Messages and iMessages in particular talk about Conversations and Contacts whereas the Scripting still refers to iMessages contacts as Buddies for the purposes of the Script.



User uploaded file

9:36 pm Saturday; March 15, 2014


 iMac 2.5Ghz i5 2011 (Mavericks 10.9)
 G4/1GhzDual MDD (Leopard 10.5.8)
 MacBookPro 2Gb (Snow Leopard 10.6.8)
 Mac OS X (10.6.8),
 Couple of iPhones and an iPad

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript Forward Messages Attachments

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