I'm new to apple script:

Does anyone have an example of using an AppleScript to send individual emails with unique attachments for each email using an excel list? (Lots of examples out there sending emails with an attachment, but no one seems to have done it with different attachments for each mail???)

Basically I have an email list in excel which holds all email addresses and file names


a Folder with each excel file in it.

I want to send the email to user in email list and attach file to email and on a loop until complete. Each person should receive the same email but will have different file attached.

Can someone provide example please?

  • How is the Excel workbook laid out, how many columns, what order, are the paths of the files to be attached in fully qualified POSIX path filename or HFS path, etc.? Please include a representative example in the edited question. Oct 12, 2020 at 17:30

1 Answer 1


set theWorkbookFile to choose file with prompt "Please select an Excel workbook file:" set theWorkbookName to name of (info for theWorkbookFile) tell application "Microsoft Excel" open theWorkbookFile set theWorkbook to workbook theWorkbookName set peremail to value of used range of active sheet end tell

--This is the part that I am stuck on???--

tell application "Finder" activate set theAttachmentFile to every file of "Macintosh HD:Users:j:Box:Email test:"whose name contains (peremail as Unicode text) -- the attachment path end tell

repeat with aRow in peremail set {theEmail, theName} to aRow tell application "Mail" set newMessage to make new outgoing message with properties {sender:thesender, subject:"Order"} tell newMessage set content to "XXXX" make new to recipient at end of to recipients with properties {name:theName, address:theEmail} tell content of newMessage

            make new attachment with properties {file name:theAttachmentFile as alias} at after the last word of the last paragraph
        end tell
        delay 3
    end tell
end tell

end repeat

  • 1
    Welcome to Ask Different! Since you have "--This is the part that I am stuck on???--" in this (so-called) answer, this is really not an answer and looks like it is supposed to be part of the original question. Please delete this non-answer and edit its content into your OP. Thanks! Oct 12, 2020 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .