Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Mail.app in OS X 10.7. In a text file I have a list with 500 different email addresses, extracted from my address book, each one in a different line.

I would like to send some christmas. So I prepared a text template and I would like to send same text in an email to each recipient, just to each one. So I wonder if using some scripting this could be done in a non-interactive way in OS X. In Linux I think this could be done using "mutt".

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If the body of the message is the same, then the best and easiest way to do this is to just copy and paste all the addresses into the BCC field (which you may need to unhide: View → Bcc Address Field). You can just copy and paste the contents of the whole text file, and Mail will detect the addresses properly.

Doing it this way means you're only sending out one email to your server, but each recipient sees it as addressed solely to them, and can't see anyone else's addresses.

That said, if you really want to automate this, I came up with an AppleScript for you. Open AppleScript Editor and paste in this code:

set theAddressFile to (choose file with prompt "Select Addresses File")
set theTextFile to (choose file with prompt "Select Message Body File")

-- read each line into a list, discarding newline at end of file
set theEmails to read theAddressFile using delimiter (ASCII character 10)

set theBodyText to read theTextFile

tell application "Mail"
    repeat with anEmail in theEmails
        set theNewMessage to make new outgoing message with properties {subject:"My Subject", content:theBodyText, visible:false}
        tell theNewMessage
            make new to recipient at end of to recipients with properties {address:anEmail}
            send
        end tell
    end repeat
end tell

When run, it will prompt you for two files — the first one for the addresses (one per line, nothing else or it will break), and the second one is the body text. It will then send (using Mail.app) one email to each address. You'll want to change the subject in the code (currently My Subject) to something appropriate.

share|improve this answer
    
Excellent! I will test it and let you know, great work. –  flow Dec 19 '12 at 16:28
    
I'm curious, is there a reason a standard BCC wouldn't suffice? It's more or less designed for this sort of situation. –  robmathers Dec 19 '12 at 17:35
    
When I do that, the receiver sees that there is something on the BCC –  flow Dec 19 '12 at 17:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.