On Nov 4, 2005, at 9:27 PM, Robert Nicholson wrote:
You can drag email addresses over groups in Address Book but I don't see see anyway to drag muitple addresses at one time.So for instance you have a smart mailbox to show you the messages you want and then you want to get those email addresses into a group in Address Book.
The first hurdle is that Applescript doesn't know about smart mailboxes. You would either have to write the same criteria into Applescript that is used for the smart mailbox, or would have to use some other method to group the mail.
Here is a proposed solution:
tell application "Mail"
tell message viewer 1
set fits_criteria to messages ¬
whose subject contains "Test"
repeat with this_message in fits_criteria
set this_address to ¬
extract address from sender of this_message
my add_to_address_book(this_address)
end repeat
end tell
end tell
on add_to_address_book(address_)
tell application "Address Book"
set new_contact to make new person
tell new_contact
make new email at beginning of emails ¬
with properties ¬
{label:"Test", value:address_}
end tell
add new_contact to group "Test"
save addressbook
end tell
end add_to_address_book
It is not a complete solution because it doesn't populate the various name-related properties of the contacts. I'm leaving that as "an exercise for the student." <g>
-- Michelle
--
Social Security Privatization: a solution in search of a problem.