I am able to successfully send out an email with an attachment to a single email address using the code below:
on run argv
set theSubject to (item 1 of argv)
set theAttachmentFile to (item 2 of argv)
tell application "Mail"
set theAddress to "recipient1@domain.com" -- the receiver
set theSignatureName to "Sig" -- the signature name
set msg to make new outgoing message with properties {subject:theSubject, visible:true}
tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
tell msg to make new attachment with properties {file name:theAttachmentFile as alias}
set message signature of msg to signature theSignatureName
send msg
end tell
end run
However, I can't figure out how to change this code to send the email to both recipient1@domain.com and recipient2@domain.com. Does anyone know how I would go about doing so? I'm very new to AppleScript, so I'd greatly appreciate the help!
Best Answer
I was able to tweak the
set theAddress
line and thetell msg to make new to recipient
line to make the following code run as intended: