Mailsmith
 Other Programs
 Scripts
  Mailsmith.scpt
  Archive to sub-mailbox
  Check Spelling
  Find reply
  Change font size
  Submit Script to JEM
  Fix common spelling errors
  Setting SMTP server
  URL from Safari
  Address from AB
  linkMunge
  Export to Address Book
  Saving attachments
  Digest Script
  File with same
  POP window position
  Position of new windows
  iCal and Mailsmith
  Edit From Line
  Modified Thread Script
  Reply to Selection
  Temporary Text Window
  Compact gain
  Tracking backups
  Edit subject
  Googler
  Auto-rewrap
  MMA
  SMTP server
  Open, fetch, and close
  URL Manager
  BrainForest
  Thread by Author
  Thread by subject
  Export Email
  Get Selection
  Read Addresses
  Export Email
  Organize Email
  Account setup
  Mailsmith 2 BBEdit
  BBEdit 2 Mailsmith
  Search II
  Check One
  Delete Enclosure
  Open, fetch, close
  Set Answered
  Set Redirected
  Empty Trash
  List found
  Print Several
  Del. old. msg.
  Delete Enclosures
 Accounts
 Address Book
 Editing
 Filters
 General
 Import/Export
 Links
 Mailboxes
 Memory
 Scripting
 Speed
 send/receive
 Tips/Tricks
|
Space to be gained by compacting |
| Author |
Brennan Young
|
| Last modified |
2002-11-22
|
|
What is this?
Throws up a text window displaying which mailboxes would most benefit from compacting.
|
property wname : "Space to be gained by compacting mailboxes"
property fntHeight : 10
property windowFurnitureV : 120 -- extra pixels used by window drag bar etc.
property winWidth : 370 -- big enough to display full title using 'Charcoal'
property winLeft : 20 -- left offset of window
property winTop : 20 -- top offset of window
on run
gatherer's initialise()
tell application "Mailsmith"
activate
set mbxs to (a reference to mailboxes) -- this will give us the top level
my processBoxes(mbxs)
set str to gatherer's getFormattedString()
set mboxCount to gatherer's getmboxCount()
set charDimV to ((mboxCount + 1) * fntHeight)
set r to (winLeft + winWidth)
set b to (winTop + charDimV + windowFurnitureV)
if not (text window wname exists) then
tell (make new text window with properties {bounds:{winLeft, winTop, r, b}})
set name to wname
end tell
end if
tell window wname
set contents to str
save to (((path to "flnt") as string) & "SpaceToBeGained")
end tell
end tell
end run
on processBoxes(mbxs)
tell application "Mailsmith"
set cm to (count mbxs)
repeat with m from 1 to cm
set thisMailbox to (get item m of mbxs)
set thisMailboxName to (get name of thisMailbox)
set thisMailBoxSize to (get size of thisMailbox)
set thisMailBoxSpace to (get free space of thisMailbox)
set onePercent to (thisMailBoxSize / 100)
set percentWasted to (round (thisMailBoxSpace / onePercent))
if percentWasted > 0 and thisMailBoxSpace > 2000 then
my gatherer's addMailBoxRecord(thisMailboxName, percentWasted)
end if
-- now process any sub mailboxes
set subBoxes to (a reference to (mailboxes of thisMailbox))
set innerCount to (count subBoxes)
if innerCount > 0 then -- there *are* sub mailboxes...
tell thisMailbox
my gatherer's indent()
my processBoxes(subBoxes)
my gatherer's undent()
end tell
end if
end repeat
end tell
end processBoxes
script gatherer
property mboxRecords : {}
property longestMailboxName : 0
property indentLevel : 0
property mboxCount : 0
on initialise()
set mboxRecords to {}
set longestMailboxName to 0
set indentLevel to 0
set mboxCount to 0
end initialise
on addMailBoxRecord(thisMailboxName, percentWasted)
-- add indent string to beginning of name
set indentStr to ""
repeat with i from 1 to indentLevel
set indentStr to indentStr & " "
end repeat
set thisMailboxName to ((indentStr & thisMailboxName) as string)
set thisMailboxNameLength to (count thisMailboxName)
if (thisMailboxNameLength > longestMailboxName) then
set longestMailboxName to thisMailboxNameLength
end if
set thisMboxRecord to {name:thisMailboxName, waste:percentWasted}
set end of mboxRecords to thisMboxRecord
set mboxCount to mboxCount + 1
end addMailBoxRecord
on getmboxCount()
return mboxCount
end getmboxCount
on indent()
set indentLevel to indentLevel + 1
end indent
on undent()
set indentLevel to indentLevel - 1
end undent
on getFormattedString()
set cm to (count mboxRecords)
set str to ""
set longestLine to 0
set r to ""
repeat with mbr in mboxRecords
set thisLine to r
set nambr to (name of mbr)
repeat while true
if ((count nambr) > longestMailboxName) then
exit repeat
else
set nambr to (nambr & " ")
end if
end repeat
set wasmbr to ((waste of mbr) as string)
repeat while true
if ((count wasmbr) is less than or equal to 3) then
exit repeat
else
set wasmbr to (" " & wasmbr)
end if
end repeat
set thisLine to thisLine & nambr
set thisLine to thisLine & wasmbr & "%"
set thisLineLen to (count thisLine)
if (thisLineLen > longestLine) then
set longestLine to thisLineLen
end if
set thisLine to thisLine
set r to return
set str to str & thisLine
end repeat
set str to str & return & return & "Results generated: " & ((current date) as string)
return str
end getFormattedString
end script
|