How can I get the subject of mail

J

Jmlover

@pop = Net::pOP3.new('pop.163.com')
@pop.start(@username, @password)

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

@pop.finish


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


Thank you!
 
C

Craig

@pop = Net::pOP3.new('pop.163.com')
@pop.start(@username, @password)

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

@pop.finish

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

Thank you!

Here is one way.

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

Cheers,

Craig
 
M

Mike Stok

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


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('(e-mail address removed)', '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 Stok <[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-----
 

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,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top