set _description to "Alle nicht markierten und gelesenen Nachrichten einer IMAP-Inbox werden in den Ordner 'Archiv' auf dem jeweiligen Server verschoben."
tell application "Mail"
display alert "Archivieren?" buttons {"Abbruch", "Archivieren"} cancel button 1 message _description
repeat with _acct in imap accounts
set _acct_name to name of _acct
set _inbox to _acct's mailbox "INBOX"
try
if (_acct_name is "Gmail") then
set _archive_box to _acct's mailbox "[Gmail]/Alle Nachrichten"
else
set _archive_box to _acct's mailbox "Archiv"
end if
on error
display alert "Kein Archiv-Ordner für das Konto '" & _acct_name & "' gefunden. Sie müssen zuerst einen IMAP-Ordner namens 'Archiv' erstellen!"
return -- Stop the script
end try
set _msg_list to (every message of _inbox whose flagged status is false and read status is true)
if (_msg_list's length > 0) then
move _msg_list to _archive_box
end if
end repeat
end tell