Ok, I am not good in scripting, sometimes I only modify existing ones. Now I need to quickly find a solution to send more than 1500 emails… I’ve a database (in excel), with name/surname/email etc. and a folder in finder with all images named <name_surname>.jpg. I need to compose and send an email for each destination with its jpeg attachment. The message body and the subject in each mail will be the same, no matters.
S A V E M E from doing this manually…
L
Hi,
this is a starting point
set imagesFolder to (path to desktop as text) & "Images:"
tell application "Microsoft Excel" to set usedRange to value of used range of active sheet
set theBody to "Hello World"
repeat with anItem in usedRange
set {firstName, surName, emailAddress} to anItem
set theSubject to ("Picture " & firstName & space & surName)
try
tell application "System Events" to set imageFile to path of file (firstName & "_" & surName & ".jpg") of folder imagesFolder
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
-- set visible to true
make new to recipient at end of to recipients with properties {address:emailAddress}
tell content to make new attachment with properties {file name:imageFile as alias} at after the last paragraph
end tell
-- send newMessage
end tell
end try
end repeat
imagesFolder is a folder “Images” on desktop.
In Excel the columns A to C contain first name, surname and email address.
To send the messages uncomment the send line.
To make the message visible, uncomment the visible line.