Hi all,
Is there a library to read emails (rfc822) stored in a mailbox or a maildir ?
Thank you,
Stephane
Hi all,
Is there a library to read emails (rfc822) stored in a mailbox or a maildir ?
Thank you,
Stephane
require 'net/pop'
....
http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/index.html
Kind regards
robert
Stephane Wirtel <stephane.wirtel@com.gmail> wrote:
Hi all,
Is there a library to read emails (rfc822) stored in a mailbox or a
maildir ?Thank you,
Stephane
It's difficult to figure out what you want. Your subject
says "net/pop3", but the body seems to imply the messages are
stored on a local filesystem.
Tim
Stephane Wirtel <stephane.wirtel@com.gmail> wrote:
Is there a library to read emails (rfc822) stored in a mailbox
or a maildir ?
require 'net/pop'
...http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/index.html
Thanks for this documentation, but in fact, I want to store my emails in a rdbms (postgresql, ... (why not sqlite3)).
To separate each field of the header, and to create a small database.
And why not, create a small gui with gtk2.
Stef
Tim Hammerquist wrote:
Stephane Wirtel <stephane.wirtel@com.gmail> wrote:
Is there a library to read emails (rfc822) stored in a mailbox
or a maildir ?It's difficult to figure out what you want. Your subject
says "net/pop3", but the body seems to imply the messages are
stored on a local filesystem.Tim
Hi Tim,
Yes, sorry. In fact, I would like to create a small client to retrieve my mail from my isp, and to store each mail into a database.
So, with which library can I analyze the header ?
Stef,
require 'net/pop'
...http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/index.html
Thanks for this documentation, but in fact, I want to store my
emails in a rdbms (postgresql, ... (why not sqlite3)).
Please choose a less misleading subject next time.
To separate each field of the header, and to create a small database.
This might help.
http://www.dagbrown.com/software/gurgitate-mail/
For the database there's a lot of tools around (starting from DBD/DBI, a standard DB interface) to more sophisticated things like ActiveRecord etc. Depends on your needs.
And why not, create a small gui with gtk2.
I'm not so into GUI programming but I'm sure someone else will provide pointers. I'm sure you'll also find them easily via Google.
Regards
robert
Stephane Wirtel <stephane.wirtel@com.gmail> wrote:
Great minds think alike!!! ![]()
I'm working on this as well.
Here's my initial attempt with the oblig disclaimer that it needs lots of
further work!
require 'sqlite3'
class FileDataSource
def initialize(name)
#@lines = IO.readlines(name);
@file = File.open(name)
end
def getLine
#return @lines.shift
@file.gets
end
end
def processMessage(cnt, db, message)
fldFrom=""
fldTo=""
fldSubject=""
fldDate=""
message.each { |lne|
if lne =~ /^From: (.*)/
fldFrom = $1
end
if lne =~ /^To: (.*)/
fldTo = $1
end
if lne =~ /^Subject: (.*)/
fldSubject = $1
end
if lne =~ /^Date: (.*)/
fldDate = $1
end
}
db.prepare "insert into email ( 'Id', 'From','To','Subject','Date','Message'
) values ( ?, ?, ?, ?, ?, ?)" do |stmt|
stmt.bind_params cnt, fldFrom, fldTo, fldSubject, fldDate,SQLite3::Blob.new(
message.to_s )
stmt.execute
end
puts "Added Record #{cnt} Subject:#{fldSubject}"
end
dataSource = FileDataSource.new("ozemail.inbox")
cnt = 0
db = SQLite3::Database.open( "sqllite\\demo.db", :driver => "Native" )
message =
while line = dataSource.getLine
if line =~ /^From /
cnt+=1
processMessage(cnt, db, message)
message =
else
message << line
end
end
db.close
On 10/18/05, Stephane Wirtel <stephane.wirtel@com.gmail> wrote:
> require 'net/pop'
> ...
>
> http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/index.html
>
Thanks for this documentation, but in fact, I want to store my
emails in a rdbms (postgresql, ... (why not sqlite3)).
--
Into RFID? www.rfidnewsupdate.com <http://www.rfidnewsupdate.com> Simple,
fast, news.