Sunday, March 7, 2010

AddressBook AppleScript Example

Here’s a simple AppleScript that exports all of the email addresses in your Mac OS X address book as a comma-separated list:

tell application “Address Book”
set emailList to {}
set peopleCount to (count every person)
repeat with i from 1 to peopleCount
set emailList to emailList & (get value of every email of person i)
end repeat

set outputFileName to choose file name with prompt “Save address book as text:” default name “addressbook.txt”

set outputFile to open for access outputFileName with write permission
repeat with e in emailList
write e & “, ” to outputFile
end repeat
close access outputFile
end tell

No comments:

Post a Comment