I'm running an applescript to extract all the email adress from all the messages in my boss's inbox and it freezes on his computer and works fine on mine.
my computer is running Snow leopard with mail 4.6 and his is running Lion with mail 5.3 if that makes any difference.
Also my inbox only has around 400 mails since i don't usually use mail and only got those messages to test the script and his has over 60 000.
The script ran through my email in around 20 seconds and on his took 2 minutes to do 40 then froze.
I was wondering if there was anything wrong with the code that could cause it to freeze in his higher version or due to the increase in email present.
On another note i know that writing them all one by one is probably counter-productive because the script i adapted this from was sorting the adresses and removing duplicates before writing them to the file but i thought that due to the large number of mails that it would speed the process and use less memory to just write them. PLus the counters helps to know where the script is at.
here is the code :
tell application "Finder" to set ptd to path to documents folder as string
set theFile to ptd & "extracted3.txt"
set theFileID to open for access theFile with write permission
set counter to 0
tell application "Mail"
set selectionMessage to selection -- just select the first message in the folder
set thisMessage to item 1 of selectionMessage
set theseMessages to (every message in (mailbox of thisMessage))
repeat with eachMessage in theseMessages
try
set counter to counter + 1
set theFrom to (extract address from sender of eachMessage)
set theFromName to (extract name from sender of eachMessage)
set theFromTemp to theFrom & "," & theFromName & "," & counter
write theFromTemp & return to theFileID as «class utf8»
if (address of to recipient) of eachMessage is not {} then
repeat with i from 1 to count of to recipient of eachMessage
set theTo to (address of to recipient i) of eachMessage as string
set theToName to (name of to recipient i) of eachMessage as string
set theToTemp to theTo & "," & theToName & "," & counter
write theToTemp & return to theFileID as «class utf8»
end repeat
end if
if (address of cc recipient) of eachMessage is not {} then
repeat with i from 1 to count of cc recipient of eachMessage
set theCC to (address of cc recipient i) of eachMessage as string
set theCCName to (name of cc recipient i) of eachMessage as string
set theCCTemp to theCC & "," & theCCName & "," & counter
write theCCTemp & return to theFileID as «class utf8»
end repeat
end if
end try
end repeat
end tell
close access theFileID