Monday, May 20, 2019

#1 2019-05-14 07:34:24 am

From:: Sydney
Registered: 2014-08-20
Posts: 66

Messages – send multiple images

I'm trying to send multiple images in a single Message using AppleScript.

I can do it manually in iOS Messages by selecting images in Photos and sending them all in one message to a recipient. Otherwise on the Mac I can drag multiple images into the message pane of the Messages app. It seems to create multiple paragraphs, with each image on its own paragraph. Using AppleScript on the Mac however, I can only see how to send one image at a time. This results in a new notification for each image which is not ideal.

Looking at the Messages AppleScript dictionary, it seems multiple attachments can be added to rich text but I can't work out how to create a rich text object or a message object that can accept attachments or images. Any ideas?

Here is the code that can send images as multiple messages.


   tell application "Messages"
   set targetService to (1st service whose service type = iMessage)

   --This is the person's contact as text
   set MessengerContact to "1234 123 123"

   --This is the buddy that corresponds to this text
   set targetBuddy to buddy MessengerContact of targetService

   --The variable FileList is a list of aliases
   repeat with i from 1 to (count FileList)
       set targetAttach to item i of FileList
       send targetAttach to targetBuddy
   end repeat


Last edited by davidhmorgan (2019-05-14 07:20:49 pm)



#2 2019-05-18 07:54:36 pm

Registered: 2019-03-03
Posts: 122

Re: Messages – send multiple images

To create a script that binds multiple files to a single message is a useless task. This is because the total size of files should not exceed 1-10 MB. Simply the server will refuse to send a huge message. Instead, you just need to build a text that includes a list of links to these files.  Building similar text with AppleScript is simple task. You create empty string, then add in loop each link to end of this string.

Maybe Messages allow adding links like nextLoopLinkString as URL. I did not try, I do not know. If not, add them as plain text. Use & return at the end of each added link.

Last edited by KniazidisR (2019-05-18 08:22:43 pm)

macOS Mojave -- version 10.14.4
Safari -- version 12.1



#3 Yesterday 08:27:45 pm

From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 392

Re: Messages – send multiple images

I don't have an answer on how to attach the files, but in reply to KniazidisR's response - a lot of texted image jpg's are 100k or less. You could put 100 of them on a max 10 MB text message. For all we know, his goal is to attach 2 ≈30k images to each message. Doing so is not a "useless task." I text multiple images in one message to people via UI on my phone all the time and it's never caused a problem I'm aware of.

As he noted, he can accomplish what he wants via the UI, so I don't think dismissing what he wants as impractical is likely an accurate criticism.

Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)