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.

In mail, I'll get email to a list of about 50 people, all of whom need to be in my address book. Is there a way to add them all at once? I can tell it to add one at a time, but I can't seem to get it to do more than that.

share|improve this question
    
I've encountered several other people in real life asking this question in the last week. I can't find a built-in way to do this. People I've talked to seem amazed this requires an AppleScript, but it's the only thing I've come up with. –  Daniel Lawson Sep 21 '11 at 12:04

1 Answer 1

up vote 2 down vote accepted

Perhaps an AppleScript like this one can help. Note that I'm not really proficient in AppleScript, so I'm sure this can be improved, but no one has answered so far.

  tell application "Mail"
    set theSelection to selection
    set theMessage to item 1 of theSelection
    set theSubject to subject of theMessage
    tell application "Address Book"
        set theGroup to make new group with properties {name:theSubject}
    end tell
    set theRecipients to to recipients of item 1 of theMessage
    repeat with a from 1 to count theRecipients
        set theRecipient to item a of theRecipients
        tell application "Address Book"
            set theName to name of theRecipient
            tell application "Mail" to set theAddress to address of theRecipient
            set thePerson to make new person with properties {first name:name of theRecipient}
            make new email at end of emails of thePerson with properties {value:theAddress}
            add thePerson to theGroup
        end tell
    end repeat
    set theRecipients to cc recipients of item 1 of theMessage
    repeat with a from 1 to count theRecipients
        set theRecipient to item a of theRecipients
        tell application "Address Book"
            set theName to name of theRecipient
            tell application "Mail" to set theAddress to address of theRecipient
            set thePerson to make new person with properties {first name:name of theRecipient}
            make new email at end of emails of thePerson with properties {value:theAddress}
            add thePerson to theGroup
        end tell
    end repeat
    tell application "Address Book" to save
  end tell
share|improve this answer

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.