So this is a follow up to the thread here:
http://macscripter.net/viewtopic.php?id=42960
The goal is to send a group of roughly 200 emails, formatted in HTML, and attach a PDF document w/out breaking the HTML formatting.
Including the system events command A will add the file correctly, but only to one email, not the entire list. Standard Add New Attachment breaks the HTML.
Here is the code I’m working with:
tell application "Contacts"
set gp_list to the name of every group
set theGroup to the value of email of every person in group (item 1 of (choose from list gp_list))
end tell
tell application "Mail"
try
set useSignature to signature (item 1 of (choose from list (get name of every signature) with prompt "Choose Your Signature:"))
end try
activate
set theSubject to "The Subject Matter"
set theBody to " test"
repeat with i from 1 to (count of theGroup)
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody, visible:true}
tell newMessage
try
set theemailadd to item i of theGroup as rich text
make new to recipient at end of to recipients with properties {address:theemailadd}
end try
try
set message signature to useSignature
end try
end tell
tell application "System Events" to keystroke "A" using command down
--send newMessage
--delay 1
end repeat
end tell
--tell application "System Events" to keystroke "A" using command down