would like script to 'add sender's e mail address to address book'

i am very very very new to all this…I am a new Mac user…i am a ‘simpleton’ when it comes to computer use,basically.

But i am enjoying the (relative)simplicity and logic behind the way Mac works…
(so much to learn…)

I think i would like to learn a bit about applescript…I am presently looking to see if i can find some tutorials.

i would like to be able to create scripts to make my computer life simpler,and applications which i often use, quicker.

Until i learn more of the Principles of Applescript,might i ask someone to share or help me create a script (preferably the former,as i mentioned…i am at ‘ground zero’ where understanding the most basic principles of Applescript is concerned.)
my question in a nutshell
i would like a script which i could use…when i open a new e mail,i could use the script to automatically add the e mail address of the sender to my address book…(alphabetically placed).

is there any way this could be accomplished?A script which someone would give me to accomplish that task.

many thanks

Model: ibook G4
Browser: Safari 312
Operating System: Mac OS X (10.3.6)

This is built-in to Mail. Under the Message menu, select “Add Sender to Address Book” (Command-Y).

That said, if you wanted to learn more about AppleScript, this script could work in most instances (as long as the sender’s name is listed as “first last user@domain.com”):

tell application "Mail"
	set the_selection to (get selection)
	set selection_count to count the_selection
	if selection_count = 0 then
		return display dialog "Nothing is selected. Select a message and run the script again." buttons {"OK"} default button 1 with icon 1 giving up after 5
	else if (class of item 1 of the_selection) is not message then
		return display dialog "You do not have a message selected. Select a message and run the script again." buttons {"OK"} default button 1 with icon 1 giving up after 5
	else if selection_count > 1 then
		display dialog "You have multiple messages selected. Do you want to add all the senders to your Address Book?" buttons {"Cancel", "OK"} default button 2 with icon 2
	end if
	repeat with this_message in the_selection
		tell this_message
			my add_sender_to_AB(get sender)
		end tell
	end repeat
end tell

on add_sender_to_AB(the_sender)
		set the_offset to (offset of "<" in the_sender)
		set the_name to the_sender's text 1 thru (the_offset - 2)
		set the_email to the_sender's text (the_offset + 1) thru -2
		set {first_name, last_name} to {the_name's word 1, the_name's word -1}
		tell application "Address Book"
			set the_person to (make new person with properties {first name:first_name, last name:last_name})
			make new email at end of the_person with properties {value:the_email, label:"work"}
			save addressbook
		end tell
	end try
end add_sender_to_AB


:lol: many thanks,John…

(re: the command is already in my taskbar elements)…hmmm…observant aren’t i…

nevertheless THANK YOU for sharing the script with me…

I find that when i am trying to learn something, that seeing actual examples (visually) of an application helps immensely in rounding out my comprehension of the subject…

Many thanks


i’m looking for a similar script.
i want to create two rules in mail (2.0.5).

  1. If i receive a email with the subject “subscribe” → ad email-address to my addressbook
  2. If i receive a email with the subject “unsubscribe” → delete email-address from my addressbook

but i can’t find some script. do you have a idea?