This should work. If you like it, save it as an app and run it as a startup app in system preferences. If you do this, it will start 2 minutes after your computer turns on. It will then check for new subscriptions/unsubscriptions every 30 minutes. Let me know if you have problems. Ian
delay 2 * minutes
repeat
tell application "Mail"
activate
launch
delay 5
get name of accounts
set mailboxName to name of accounts
check for new mail of account mailboxName
tell application "Mail"
repeat until not (exists (first message of inbox whose first word of content is "subscribe"))
set sendername to sender of first message of inbox whose first word of content is "subscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose first word of content is "subscribe")
tell application "Address Book"
set the_person to (make new person with properties {first name:firstname, last name:lastname, email:address1})
make new email at the end of the_person with properties {value:address1, label:"work"}
save addressbook
end tell
end repeat
end tell
tell application "Mail"
repeat until not (exists (first message of inbox whose first word of content is "unsubscribe"))
set sendername to sender of first message of inbox whose first word of content is "unsubscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose first word of content is "unsubscribe")
tell application "Address Book"
delete person name1
save addressbook
end tell
end repeat
end tell
end tell
delay 30 * minutes
end repeat
If you want it setup to read the subject box, use this. Another thing to think about. If you are using CronniX to schedual things on your computer, you can time this too. If you do this, just cut off the “delay 2* miutes”, repeat, and “delay 30* minutes” parts.
delay 2 * minutes
repeat
tell application "Mail"
activate
launch
delay 5
get name of accounts
set mailboxName to name of accounts
check for new mail of account mailboxName
tell application "Mail"
repeat until not (exists (first message of inbox whose subject is "subscribe"))
set sendername to sender of first message of inbox whose subject is "subscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose subject is "subscribe")
tell application "Address Book"
set the_person to (make new person with properties {first name:firstname, last name:lastname, email:address1})
make new email at the end of the_person with properties {value:address1, label:"work"}
save addressbook
end tell
end repeat
end tell
tell application "Mail"
repeat until not (exists (first message of inbox whose subject is "unsubscribe"))
set sendername to sender of first message of inbox whose subject is "unsubscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose subject is "unsubscribe")
tell application "Address Book"
delete person name1
save addressbook
end tell
end repeat
end tell
end tell
delay 30 * minutes
end repeat
ok, here is your final script. It will only add a name if it does not exist. It will delete every copy of a name if it exists. Also, fill in the name of the group you are putting these into. For exmple, if you have a group name in the addressbook called “website”, enter that group name where designated below. I took the repeat out. I do not know how to run the script as you say. Start a new topic that asks about that. Maybe you can use the automator? Hope this helps!
tell application "Mail"
activate
launch
delay 5
get name of accounts
set mailboxName to name of accounts
check for new mail of account mailboxName
tell application "Mail"
repeat until not (exists (first message of inbox whose subject is "subscribe"))
set sendername to sender of first message of inbox whose subject is "subscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose subject is "subscribe")
tell application "Address Book"
repeat until exists person name1
set the_person to (make new person with properties {first name:firstname, last name:lastname, email:address1})
add the_person to group "website update" *****HERE!!!!!
make new email at the end of the_person with properties {value:address1, label:"work"}
save addressbook
end repeat
end tell
end repeat
end tell
tell application "Mail"
repeat until not (exists (first message of inbox whose subject is "unsubscribe"))
set sendername to sender of first message of inbox whose subject is "unsubscribe"
set name1 to extract name from sendername
set address1 to extract address from sendername
set firstname to word 1 of name1
set lastname to word 2 of name1
delete (first message of inbox whose subject is "unsubscribe")
tell application "Address Book"
repeat until not (exists (person name1))
delete person name1
end repeat
save addressbook
end tell
end repeat
end tell
end tell