I'm trying to compare all emails from the "Mail" application on an old mac to a newer one.
I'm trying out AppleScript for the first time to help me. I'm good at using C-family programming languages but have difficulty getting my head around the AppleScript syntax.
My idea is to create a text file for every mailbox. Each text file line should contain the subject + sender + date of a mail.
I've got the following AppleScript code:
tell application "Mail"
set all_mailboxes to every mailbox
set the mailbox_count to the count of all_mailboxes
repeat with i from 1 to the mailbox_count
set this_mailbox to item i of all_mailboxes
log name of this_mailbox
-- instead of logging the name, create an empty text file called name + ".txt"
set all_messages_in_this_mailbox to every message in this_mailbox
set the message_count to the count of all_messages_in_this_mailbox
repeat with i from 1 to the message_count
set this_message to item i of all_messages_in_this_mailbox
set this_subject to subject of this_message
log this_subject
set this_sender to sender of this_message
log this_sender
try
set this_date to date of this_message
log this_date
on error
log "NO DATA"
end try
-- instead of logging the subject+sender+data, add a line to the textfile with it
end repeat
end repeat
end tell
I can't get my head around how to create a text file and add text to it. Any help would be very appreciated!
(If anyone has other suggestions for comparing Apple Mail mailboxes, please let me know.)
(Actually, I'd also be interested in learning if it's somehow possible to do stuff like this in e.g. Java/C# syntax. That would make it so much easier for me! Thanks again! )