[imapfilter-devel] Dated archive

Brendan Hide brendan at swiftspirit.co.za
Mon Mar 7 18:21:47 EET 2011


Thank you so much, Rob. :)

Sorry so late on my response. I'll need to adjust the filter that 
filtered this. ;)

On 2011/02/27 17:48, Rob Austein wrote:
> This is what I use, after Lefteris straightened me out on a few of the
> details.  Hack as necessary.
>
>
>
>
>
> myserver = IMAP {
>     server   = "myserver.example.org",
>     username = "me",
>     password = "secret",
>     ssl      = "tls1"
> }
>
> month = {
>     ["Jan"] = "01", ["Feb"] = "02", ["Mar"] = "03", ["Apr"] = "04", ["May"] = "05", ["Jun"] = "06",
>     ["Jul"] = "07", ["Aug"] = "08", ["Sep"] = "09", ["Oct"] = "10", ["Nov"] = "11", ["Dec"] = "12"
> }
>
> -- Archive old messages.  This is (sort of) a recreation of something
> -- that existed in the original 0.x version of imapfilter, rewritten
> -- in LUA.  Move old unflagged seen messages to archive mailboxes
> -- named using the internal date of the message.
>
> function archive(days, mailboxes)
>     for _, mailbox in ipairs(mailboxes) do
>        results = myserver[mailbox]:is_older(days) * myserver[mailbox]:is_seen() * myserver[mailbox]:is_unflagged()
>        targets = {}
>        for _, message in ipairs(results) do
> 	 mbox, uid = unpack(message)
> 	 date = mbox[uid]:fetch_date()
> 	 _, _, m, y = string.find(date, "%d+-(%a+)-(%d+)")
> 	 target = mailbox .. "." .. y .. "." .. month[m]
> 	 if targets[target] == nil then
> 	    targets[target] = Set {}
> 	 end
> 	 table.insert(targets[target], message)
>        end
>        for target, msgset in pairs(targets) do
> 	 msgset:move_messages(myserver[target])
>        end
>     end
> end
>
> archive(120, { "fee", "fie" })
> archive(14,  { "foe", "fum" })
>
>
> _______________________________________________
> Imapfilter-devel mailing list
> Imapfilter-devel at lists.hellug.gr
> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel


-- 
__________
Brendan Hide
Mobile: +27 83 448 3867
Mobile: brendan.cell at swiftspirit.co.za (plain text only please)
Web Africa - Internet Business Solutions - http://www.webafrica.co.za/?AFF1E97

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20110307/15d5c78d/attachment.html>


More information about the Imapfilter-devel mailing list