applescript help


the script below following: adds selected email addresses in mail group in address book. done based on sender (see text in bold). however, want modify script recipients added. please help!

thank you!!!
johannes

/////////////////



set baselist {}
set namelist {}
set emaillist {}

-- emails "mail"
tell application "mail"
set mess_list selected messages of front message viewer
repeat this_email in mess_list
set toemail extract address (sender of this_email)
set toname extract name (sender of this_email)

if toemail equal toname set toname ""
set end of emaillist toemail
set end of namelist toname
end repeat
end tell

-- add address book
tell application "address book"
set groupnames name of every group
set groupresponse choose list groupnames prompt "select group"
if groupresponse false return
set thegroup item 1 of groupresponse
set thepeople {}
repeat 1 count of emaillist
set thiseaddr change_case((item of emaillist), 0)
ignoring case
set theperson (people value of every email contains thiseaddr)
end ignoring
if theperson {} then
set tid applescript's text item delimiters
set applescript's text item delimiters " "
set firstname ""
set lastname ""
if (count of text items of (item of namelist)) > 0 then
set lastname last text item of (item of namelist)
if (count of text items of (item of namelist)) > 1 then
set firstname first text item of (item of namelist)
end if
end if
set theperson make new person @ end of people properties {first name:firstname, last name:lastname}
tell theperson make new email @ end of emails properties {label:"work", value:thiseaddr}
else
set theperson item 1 of theperson
end if
add theperson group thegroup
end repeat
save addressbook
end tell

on change_case(this_text, this_case)
if this_case 0 then
set comparison_string "abcdefghijklmnopqrstuvwxyz"
set source_string "abcdefghijklmnopqrstuvwxyz"
else
set comparison_string "abcdefghijklmnopqrstuvwxyz"
set source_string "abcdefghijklmnopqrstuvwxyz"
end if
set new_text ""
repeat this_char in this_text
set x offset of this_char in comparison_string
if x not 0 then
set new_text (the new_text & character x of source_string) string
else
set new_text (the new_text & this_char) string
end if
end repeat
return new_text
end change_case
 



Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

need help with itunes 7.7

Rogers Listens.

Font book issue in firefox3