How do I access the following?

B

Brandon Phelps

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]}>]
 
J

Jordi Bunster

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!
 
B

Brandon Phelps

Jordi said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top