Apple script email to multiple address?

Posted on
Wed Oct 14, 2015 4:47 pm
T-Power offline
User avatar
Posts: 220
Joined: May 10, 2010

Apple script email to multiple address?

Hello Good People,

Can some please help me with my code.
It works perfectly for sending to one address. But when I tried adding another address it causes the beach ball to appear on the Finder and nearly freezes the computer.

Code: Select all
tell application "SecuritySpy"
   capture image camera number 4 as "/Users/macmini/Desktop/Mailbox/Mailbox.jpg"
end tell

set theSubject to "Mailbox Sensor Detection"
set theSender to "billybob@aol.com"
set theAddress to "jimbob@aol.com"
set theAddress to "littlebob@aol.com"
set theAttachment to "/Users/macmini/Desktop/Mailbox/Mailbox.jpg"

tell application "Mail"
   set theMessage to make new outgoing message with properties {subject:theSubject, sender:theSender}
   
   tell theMessage
      set visible to false
      make new to recipient at end of to recipients with properties {address:theAddress}
      make new attachment with properties {file name:theAttachment} at after the last paragraph
   end tell
   send theMessage
   delay 10
end tell

tell application "System Events"
   set visible of process "Mail" to false
end tell




The code below works but was wondering how I could streamline it for adding multiple addresses?

Code: Select all
tell application "SecuritySpy"
   capture image camera number 4 as "/Users/macmini/Desktop/Mailbox/Mailbox.jpg"
end tell

set theSubject to "Mailbox Sensor Detection"
set theSender to "billybob@aol.com"
set theAddress to "jimbob@aol.com"
set theAttachment to "/Users/macmini/Desktop/Mailbox/Mailbox.jpg"

set theSubject to "Mailbox Sensor Detection"
set theSender to "billybob@aol.com"
set theAddress to "littlebob@aol.com"
set theAttachment to "/Users/macmini/Desktop/Mailbox/Mailbox.jpg"

tell application "Mail"
   set theMessage to make new outgoing message with properties {subject:theSubject, sender:theSender}
   
   tell theMessage
      set visible to false
      make new to recipient at end of to recipients with properties {address:theAddress}
      make new attachment with properties {file name:theAttachment} at after the last paragraph
   end tell
   send theMessage
   delay 10
end tell

tell application "System Events"
   set visible of process "Mail" to false
end tell



T.I.A.

MacMini 2.3 GHz Intel Core i7 16GB DDR3
Indigo Pro 2022.1 macOS Mojave 10.14.6

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests