How can I get the subject of mail

@pop = Net::POP3.new(‘pop.163.com’)
@pop.start(@username, @password)

@pop.each_mail do |m|
          # How can I get the subject of me$B!)e(B
    # e$B!A!A!A!A!A!A!A!A!A!A!A!A!A!A!A!Ae(B
    # By m.pop?
end

@pop.finish

By the way, can I only get the mail header? How?

Thank you!

On May 31, 1:46 am, Jmlover [email protected] wrote:

By the way, can I only get the mail header? How?

Thank you!

Here is one way.

puts m.pop.scan(/Subject:(.+)$/)

Cheers,

Craig

On Jun 1, 2:23 am, Craig [email protected] wrote:

Cheers,

Craig

Thank you for your reply!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jun 1, 2008, at 1:54 AM, Jmlover wrote:

end

Cheers,

Craig

Thank you for your reply!

You can use the header method if you are only interested in the header:

#!/usr/bin/env ruby

require ‘net/pop’
pop = Net::POP.new(‘pop.example.com’)
pop.start(‘[email protected]’, ‘password’) do |pop|
pop.each_mail do |mail|
puts mail.header.scan(/^Subject: (.+)/)
end
end

http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/classes/Net/POPMail.html

Mike


Mike S. [email protected]
http://www.stok.ca/~mike/

The “`Stok’ disclaimers” apply.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAkhCkQkACgkQnsTBwAWZE9rFAgCfdfz9a7fGAAmLNlt7Tolgj9J/
Xb4AoIe1vxT1NBZ/01iFeirSLOSChPrR
=Bqet
-----END PGP SIGNATURE-----