From: William Webber Date: 2003-09-01T20:27:12+09:00 Subject: Re: Newbie question re: 'net' On Mon, Sep 01, 2003 at 06:27:47PM +0900, dhtapp wrote: [snip] > require 'net/pop' > mailbox = Net::POP3::new( "pop.west.cox.net" ) > mails = [] > mailbox.start( "dhtapp", ) { mails = mailbox.mails } > print "# of mails: ", mails.size, "\n" > mails.each { |mail| p mail.header, "\n" } [snip] > I've tried moving the "p mail.header" up as a block to the mailbox.start > call, thinking that maybe the mailbox was closed by the time I tried to > print the headers out, Certaily, this is correct. Net::POPMail objects download the contents of the mail item on demand, using a reference to the Net::POP3 object that they're drawn from, so fetching the headers or body will only work while the POP3 object is still open (in your example, inside the mailbox.start block). However... > but it made no difference. Can anyone point me to > something obvious? I can't see anything else obviously wrong with your code. It should look something like this: require 'net/pop' mailbox = Net::POP3::new("pop.west.cox.net") mailbox.start("dhtapp", "mypassword") { print "# of mails: ", mailbox.mails.size, "\n" mailbox.mails.each { |mail| p mail.header, "\n" } } Does this also not work? William