[imapfilter-devel] analyzing 'date'

Lefteris Chatzibarbas lefcha at hellug.gr
Tue Jul 27 11:00:03 EEST 2004


On Sun, Jul 18, 2004 at 06:37:07PM +0200, Martin Kaehmer wrote:
> Hi all,
> 
> I just had a look at the new imapfilter 1.0 and couldn't find a feature I 
> was used to have in <1.0 versions: moving mails into mboxes named after the 
> date of the mails, e.g. moving a mail from June 25, 2004 into 
> archive.2004.June.
> 
> I started to write a lua function doing that, but how do I get the date of 
> a mail into the format needed for the lua function os.date?

Something like this:

  options.uid = true

  results = match(myaccount, 'mymailbox', myfilter)
  headers = fetchheaders(myaccount, 'mymailbox', { 'date' }, results)

  for msgid, msghdrs in pairs(headers) do
    _, _, month, year = string.find(msghdrs, "Date: %a+, %d+ (%a+) (%d+)")
    if month ~= nil and year ~= nil then
      print('archive.' .. year .. '.' .. month)
      -- move(myaccount, 'mymailbox', myaccount, 'archive.' .. year .. '.' .. month, { msgid })
    end
  end




More information about the Imapfilter-devel mailing list