Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am at the end of my tether. I want to send an email to a group of about 50 people, which is personalised at the very least with their name. (so that each email says "Dear Bob" or their name, and that they can't tell it's gone to loads of other people).

I am using Mac Mail and a Macbook Air running OS X 10.8.2 (12C3012).

I am new to Macs so maybe doing something stupid!

I have a smart group set up in my contacts with all their details.

I also want to attach a small pdf file to the email

I have spend ALL DAY trying to make this work through Automator, using a small test group.

I've tried starting with a message with the content, subject and attachment, set up in drafts, specifying this in automator, specifying contacts, going through group mailer and specifying the greeting and then to 'send outgoing messages'. in this case it says there is no outgoing message.

I've tried starting by writing the message in automator, finding and specifying the file to attach, specifying the contacts and then using group mailer to specify the greeting, then sending outgoing messages: in this case, it says "unrecognized selector sent to instance" and has a load of numbers.

I can see from the internet that lots of people have had similar problems, going back years but I can't find a solution. I really don't understand coding or Apple Script or anything but am willing to try anything! I want to be able to do this on a fairly regular basis so having a solution would be really amazing.

essentially all I want to do is a mail merge on email with an attachment (Ideally I would personalise it more by using fields for their organisation name in the body of the text, but I'd settle for just being able to send the email right now!) ... can anyone help me...???

share|improve this question
1  
Please consider editing this for length and showing your work in Automator - upload a picture to the internet and we can embed it if needed. The more of your work that you can show, the more likely someone can assist with an answer. –  bmike Dec 19 '12 at 17:46
add comment

1 Answer

Automator's group emailer is pretty lacking (I could get it working, but not with attachments), so I took a stab at whipping something up in AppleScript for you.

Open up AppleScript Editor and paste this in:

set theFile to choose file

set myMessage to "MESSAGE BODY GOES HERE."

set mySubject to "SUBJECT HERE"

display dialog "Please select the recipients in Address Book/Contacts"

tell application "Address Book"
    set theContacts to selection
    repeat with contact in theContacts
        my send_message(mySubject, "Dear " & first name of contact & "," & return & myMessage, value of first email of contact, theFile)
    end repeat
end tell

on send_message(theSubject, theBody, theAddress, theAttachment)
    tell application "Mail"
        set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return, visible:true}
        tell theNewMessage
            set visibile to true
            make new to recipient at end of to recipients with properties {address:theAddress}
            make new attachment with properties {file name:theAttachment} at after the last word of the last paragraph
            send
        end tell
    end tell
end send_message

First off, you'll want to insert the body of your message (everything but "Dear So and So,") where it says "MESSAGE BODY GOES HERE.". Be sure to retain the quotes wrapping it (and if you have any quotation marks within your message, you'll have to replace them with \"). Replace "SUBJECT HERE" similarly.

When you click run, it will bring up a dialog to select which file you want to attach. It will then prompt you to select the recipients in the Contacts application (select multiple ones by holding down command ⌘ and clicking on each name). When you're done, click OK. It will then compose and send an email for each contact automatically.

The format of the emails will look like this:

Dear Bob,

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

The attachment will get added at the end.

A few notes:

  • The script uses the first email that appears in a contact entry. So if you have multiple emails for someone, you may run into problems. The easiest way around this is to create duplicate contact entries with a single email.
    • If you have a lot of contacts with multiple emails, then you may need to look at a different solution for addressing the emails, which is outside the scope of this answer.
  • It will address it to the first name of the person. Change first name of contact to name of contact or last name of contact as desired.
  • You can add in an organization name somewhere, but it requires reformatting the body message and changing a bit of the code. Basically the body is assembled from the various parts on the my send_message… line, you'll have to change that depending on how you want to include the organization string.
share|improve this answer
add comment

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.