Search code examples
ruby-on-railsrubyimap

Ruby net::imap adding color categorys to emails


I am reading in a lot of emails every day using net::imap https://ruby-doc.org/stdlib-2.5.1/libdoc/net/imap/rdoc/Net/IMAP.html

I cannot seem to find a way to add a colored category to a message.

For example

imap.search(["ON","26-APR-2021"]).each do |message_id|
# my code...
# at the end of the code
  message_id.AddCatagory(blue)...
end

Solution

  • The method name would be add_category in well-written ruby. But that doesn't exist, because colours aren't a concept in IMAP. Flags do exist, and I know some clients use colours to represent flags... so the code you're probably looking for is something along the lines of

    imap.uid_store(uids, "+flags", [:Blue])

    You have to define Blue, of course. Or Important, Flagged or something. Flagged is used by many clients for vaguely important messages.