Puedo enviar con éxito un correo electrónico con un archivo adjunto a una sola dirección de correo electrónico usando el siguiente código:
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
Sin embargo, no sé cómo cambiar este código para enviar el correo electrónico a destinatario1@dominio.com y destinatario2@dominio.com. ¿Alguien sabe cómo haría para hacerlo? Soy muy nuevo en AppleScript, ¡así que agradecería mucho la ayuda!
Pude modificar la set theAddress
línea y la tell msg to make new to recipient
línea para hacer que el siguiente código se ejecutara según lo previsto:
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","recipient2@domain.com"}
set theSignatureName to "Sig" -- the signature name
set msg to make new outgoing message with properties {subject:theSubject, visible:true}
tell msg
repeat with i from 1 to count theAddress
make new to recipient at end of every to recipient with properties {address:item i of theAddress}
end repeat
end tell
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
Sí. Es posible asumiendo 1 dirección de correo electrónico por línea:
set srcFile to ((path to desktop) as text) & "myFile.txt"
set theAddresses to paragraphs of (read file srcFile as «class utf8»)
repeat with theAddress in theAddresses
# ... insert code to create and send email to each recipient "theAddress" is each email address
end repeat
Nicolás