[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sup-talk] 0/0...I made it
Philippe,
Excerpts from Philippe LeCavalier's message of Sun Feb 13 12:57:30 -0800 2011:
> Well, despite not finding a truly efficient method for autolabeling my mail
> -I'm not worried I won't, I just haven't found it yet- after 30 some days of
> due deligence my inbox is for now back to 0.
Have you tried writing a before-add-message hook? If so, what problems have you
run in to with your attempts at autolabeling?
Here's a snippet of mine:
# before-add-message.rb
def autolabel message, label
log "Adding label [#{label}] to #{message.id}"
message.add_label label
end
def autolabel_email message, regexes, label
regexes = [ regexes ] unless regexes.is_a? Enumerable
if message.recipients.any? do |recipient|
AccountManager.is_account_email? recipient.email and
regexes.any?{ |r| recipient.email =~ r }
end
autolabel message, label
end
if AccountManager.is_account_email? message.from.email and
regexes.any?{ |r| message.from.email =~ r }
autolabel message, label
end
end
unless message.nil?
autolabel_email message, /ucdavis.edu$/i, 'ucdavis'
# … lines similar to above, giving regexes or arrays of regexes and the
# desired label.
end
--
med vänlig hälsning
David J. Hamilton
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk