-- Downloaded From: http://c-command.com/scripts/spamsieve/whitelist-to-address-book -- Last Modified: 2007-08-17 global gAddresses set gAddresses to {} on loadAddressesIfNecessary() if gAddresses is not {} then return tell application "Address Book" repeat with thePerson in people repeat with theEmail in every email of thePerson set theAddress to value of theEmail copy theAddress to end of gAddresses end repeat end repeat return false end tell end loadAddressesIfNecessary on addressBookContainsEmail(theAddress) my loadAddressesIfNecessary() ignoring case return gAddresses contains theAddress end ignoring end addressBookContainsEmail on makeNewAddressBookCard(emailAddress) tell application "Address Book" set newEntry to make new person tell newEntry make new email at beginning of emails with properties {value:emailAddress} end tell end tell end makeNewAddressBookCard on ruleHasFullAddress(theRule) tell application "SpamSieve" if theRule's match style is not exact style then return false set theFields to {from field, reply to field, to field, any address, cc field, any recipient} return theRule's match field is in theFields end tell end ruleHasFullAddress tell application "SpamSieve" set theRules to selection repeat with theRule in theRules if my ruleHasFullAddress(theRule) then set theAddress to text to match of theRule if not my addressBookContainsEmail(theAddress) then my makeNewAddressBookCard(theAddress) end if end if end repeat end tell tell application "Address Book" save addressbook end tell