Export and Delete
Summary: Exports messages from large mailboxes and then deletes them from Mailsmith.
Requires: Mailsmith 1.5
Suggested Key Binding: none
Last Modified: 2019-10-02
Description
Set the pMessageThreshold property to the minimum number of messages that you want a mailbox to contain before the script will export it. Set the pExportFolder to the folder where the exported mailboxes should be saved. The script will then export and delete the messages from any mailbox containing at least pMessageThreshold messages and no unread ones.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
property pMessageThreshold : 800
property pExportFolder : "HD:Users:mjt:Mail:to file:"
on run
tell application "Mailsmith"
if connection in progress then return
set auto checking enabled to false
repeat with mbox in every mailbox
my recurse(mbox)
end repeat
set auto checking enabled to true
end tell
end run
on recurse(mbox)
tell application "Mailsmith"
my processMailbox(mbox)
repeat with submbox in every mailbox of mbox
my processMailbox(submbox)
end repeat
end tell
end recurse
on processMailbox(mbox)
tell application "Mailsmith"
set n to count of messages of mbox
if n > pMessageThreshold then
if (every message of mbox whose seen is false) = {} then
my exportMailbox(mbox)
end if
end if
end tell
end processMailbox
on exportMailbox(mbox)
tell application "Mailsmith"
set n to count of messages of mbox
activate
set mboxFile to (pExportFolder & name of mbox)
display dialog "“" & (name of mbox) & "” has " & n & " read messages. Will save in “" & mboxFile & "”."
export mbox to mboxFile
delete every message of mbox
end tell
end exportMailbox