Address Book scripting --- This looks very weird to me...
Address Book scripting --- This looks very weird to me...
- Subject: Address Book scripting --- This looks very weird to me...
- From: Bernardo Hoehl <email@hidden>
- Date: Mon, 26 Dec 2005 16:21:43 -0200
Hi List,
I have often read collegues refering to applescript as the "english like monster"...
I have come up with this script to extract every email address from my address book, and it looks to me a a good monster example. (see the script at the end of this)
Although it seems to work, it looks very weird to me. Could you folks send me your comments on how to make it simpler?
My main objective is to get every email address I have ever had any contact with, and send a newsletter this week.
Also, it looks like the returned list is not complete, I guess I would have to script my Mail.app in order to extract the addresses from those people who have ever contacted me one day. Can you guys suggest me a script for getting every email address from my Mail.app's inbox? Am I missing something? Where does Mail.app get its addresses used in the autofilling function?
Thanks!
Bernardo Höhl
Rio de Janeiro - Brazil
tell application "Address Book"
tell every person
set emailList to emails
tell emailList
set l to ""
repeat with i from 1 to the count of items in emailList
set x to ""
try
set x to value of item 1 of item i of (emailList)
end try
if x is not "" then
set l to l & x & return
end if
end repeat
set l to l & "Termino da lista 1" & return
repeat with i from 1 to the count of items in emailList
set x to ""
try
set x to value of item 2 of item i of (emailList)
end try
if x is not "" then
set l to l & x & return
end if
end repeat
set l to l & "Termino da lista 2" & return
repeat with i from 1 to the count of items in emailList
set x to ""
try
set x to value of item 3 of item i of (emailList)
end try
if x is not "" then
set l to l & x & return
end if
end repeat
set l to l & "Termino da lista 3" & return
repeat with i from 1 to the count of items in emailList
set x to ""
try
set x to value of item 4 of item i of (emailList)
end try
if x is not "" then
set l to l & x & return
end if
end repeat
set l to l & "Termino da lista 4" & return
end tell
end tell
end tell
set AppleScript's text item delimiters to return
set l to every text item of l
set l to l)
set l to l as text
set AppleScript's text item delimiters to ""
return l
on aList)
set newList to {}
repeat with i from 1 to (length of aList)
set anItem to item 1 of aList
set aList to rest of aList
if {anItem} is not in aList then set end of newList to anItem
end repeat
return newList
end removeDuplicates _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden