Noob question, if there is a better venue for this sort of question show
me. Thanks.
How could I access “Seen” displayed below?
[#<struct Net::IMAP::FetchData seqno=1, attr={“FLAGS”=>[:Seen]}>]
Noob question, if there is a better venue for this sort of question show
me. Thanks.
How could I access “Seen” displayed below?
[#<struct Net::IMAP::FetchData seqno=1, attr={“FLAGS”=>[:Seen]}>]
You have an Array with one Struct. Get the Struct, and call the FLAGS
method. Or use [“FLAGS”].
Mind you, FLAGS is also an Array, that could contain more flags than
:Seen. See the “include?” or “detect” methods on Array.
There’s also a chance your object has a method that does that for you.
Maybe “seen?”. Never used Net::IMAP.
Good luck!
Jordi B. wrote:
You have an Array with one Struct. Get the Struct, and call the FLAGS
method. Or use [“FLAGS”].Mind you, FLAGS is also an Array, that could contain more flags than
:Seen. See the “include?” or “detect” methods on Array.There’s also a chance your object has a method that does that for you.
Maybe “seen?”. Never used Net::IMAP.Good luck!
Thanks! FLAGS can have multiple items in it, but I know for certain that
IMAP server I’m working on will always only have one item or none at
all.
I got it by doing the following. I wonder is there a better way, what
I’m doing seems redundant but it’s how I got it to work.
imap = Net::IMAP.new(‘imap.mydomain.com’)
…
status = imap.fetch(message_id, ‘FLAGS’)[0].attr[‘FLAGS’]
if (status[0]).nil? then
status[0] = “UNREAD”
else
status[0] = “READ”
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs