Archiving Sent Mail with imapfilter

My “sent” folders are a morass. I think that’s true of most folks. I wrote a little script in my imapfilter config.lua to duplicate some handy functionality from the venerable pine. I’m sure it could be cleaned up a bit, but it does the job for me. On the first of the month, it creates a folder called “Sent-Monthname-Year”, and moves everything from sent that’s older than a day to it.


function moveSentMessages()
  --------------------------------
  -- On the first of the month  --
  -- move all older messages to --
  -- a date marked sent folder  --
  --------------------------------

  theDate = os.date("*t")

  months = {
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
  }

  if (theDate["day"] == 1) then
    dateString = "Sent-" .. months[theDate["month"] - 1] .. "-" .. theDate["year"]
    
    messages = personal["Sent"]:is_older(1) + personal["Sent Messages"]:is_older(1)
    messages:move_messages(personal[dateString])
  end
end

Comments are closed here.