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
|
Archive to sub-mailbox |
| Author |
Charlie Garrison
|
| Last modified |
2003-05-14
|
|
What is this?
This is a script to periodically move messages from one mailbox
to a 'date' sub-mailbox.
This script does not work very well across date boundaries. Eg.
I need to run this script on July 7 to make sure messages get
archived to the "03-06" (Jan-June'03) mailboxes. After that
date, I would then need to change the archiveMbox values to a
new date, eg. 03-12. More active mailboxes may require more
sub-mailboxes, eg. 03-01, 03-02, 03-03, 03-04, etc. Archive
mailboxes must exist for this script to work.
Also, there is a problem with this script only moving messages
older than the expireDate. I haven't been able to work it out.
If anyone can see the problem and offer a solution I would
appreciate it.
And if it's not obvious, you will need to edit the pMboxOptList
property with values for your mailbox setup.
|
(*
Archive to sub-mailbox
Written by Charlie Garrison - 15/05/2003
garrison@zeta.org.au http://www.garrison.com.au/
This is a script to periodically move messages from one mailbox to
a 'date' sub-mailbox.
*)
property pDebug : false -- show debug dialogs
-- mbox - path to mailbox
-- archiveMbox - name of mailbox to archive to, should be sub-mailbox of mbox
-- maxAge - messages must be atleast this many days old
property pMboxOptList : {¬
{name:"BBEdit", mbox:{"Mail Lists", "BBEdit"}, archiveMbox:"BBEdit 03-06", MaxAge:7}, ¬
{name:"Mailsmith", mbox:{"Mail Lists", "Mailsmith"}, archiveMbox:"MS 03-06", MaxAge:7}, ¬
{name:"mod_perl", mbox:{"Mail Lists", "mod_perl"}, archiveMbox:"mod_perl 03-06", MaxAge:7}, ¬
{name:"OSX Admin", mbox:{"Mail Lists", "OSX Admin"}, archiveMbox:"OSX_Admin 03-06", MaxAge:7}, ¬
{name:"OSX Perl", mbox:{"Mail Lists", "OSX Perl"}, archiveMbox:"OSX_Perl 03-06", MaxAge:7} ¬
}
on run
local mboxOpt
repeat with mboxOpt in pMboxOptList
archiveMbox(mboxOpt)
end repeat
beep
if pDebug is true then display dialog "Done!" buttons {"OK"} default button "OK"
end run
on archiveMbox(mboxOpt)
local mboxList, mbox, mboxName
set mboxList to mbox of mboxOpt
tell application "Mailsmith"
set topLevel to true
repeat with mboxName in mboxList
set mboxName to mboxName as string -- change from item reference to plain string
if topLevel then
set mbox to mailbox mboxName
set topLevel to false
else
set mbox to mailbox mboxName of mbox
end if
end repeat
local MaxAge, expireDate, num, msglist
set MaxAge to (MaxAge of mboxOpt) * 86400 --86400 seconds in a day
set expireDate to (current date) - MaxAge -- messges must be older to be moved
set msglist to every message of mbox whose ¬
time received is less than expireDate and seen is true ¬
and (label index = 0 or label index = 8) -- no label or Unread
if pDebug is true then
set num to count items of msglist
set boxName to name of mboxOpt
set dlgReply to display dialog boxName & " - expireDate: " & ¬
expireDate & " with count: " & num ¬
buttons {"Skip", "OK"} default button "OK"
if button returned of dlgReply is "Skip" then return
end if
try
with timeout of 600 seconds -- 10 minutes
move msglist to mailbox (archiveMbox of mboxOpt) of mbox
end timeout
on error errMsg number ErrNum from errFrom partial result errResult to errTo
if ErrNum ‚ -1703 then -- no message to move
error errMsg number ErrNum from errFrom partial result errResult to errTo
-- send error up the chain
end if
end try
end tell
end archiveMbox
|