Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > class to read an email from net/pop3 ?

Reply
Thread Tools

class to read an email from net/pop3 ?

 
 
Stephane Wirtel
Guest
Posts: n/a
 
      10-16-2005
Hi all,

Is there a library to read emails (rfc822) stored in a mailbox or a
maildir ?

Thank you,

Stephane
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      10-16-2005
Stephane Wirtel <> wrote:
> 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/libdo...doc/index.html

Kind regards

robert

 
Reply With Quote
 
 
 
 
Stephane Wirtel
Guest
Posts: n/a
 
      10-17-2005
> require 'net/pop'
> ...
>
> http://www.ruby-doc.org/stdlib/libdo...doc/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
 
Reply With Quote
 
Stephane Wirtel
Guest
Posts: n/a
 
      10-17-2005
Tim Hammerquist wrote:
> Stephane Wirtel <> 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,
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      10-17-2005
Stephane Wirtel <> wrote:
>> require 'net/pop'
>> ...
>>
>> http://www.ruby-doc.org/stdlib/libdo...doc/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

 
Reply With Quote
 
Lyndon Samson
Guest
Posts: n/a
 
      10-17-2005
------=_Part_3627_15219881.1129591760071
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 10/18/05, Stephane Wirtel <> wrote:
>
> > require 'net/pop'
> > ...
> >
> > http://www.ruby-doc.org/stdlib/libdo...doc/index.html
> >

> Thanks for this documentation, but in fact, I want to store my
> emails in a rdbms (postgresql, ... (why not sqlite3)).



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 =3D IO.readlines(name);
@file =3D File.open(name)
end
def getLine
#return @lines.shift
@file.gets
end
end


def processMessage(cnt, db, message)
fldFrom=3D""
fldTo=3D""
fldSubject=3D""
fldDate=3D""

message.each { |lne|
if lne =3D~ /^From: (.*)/
fldFrom =3D $1
end
if lne =3D~ /^To: (.*)/
fldTo =3D $1
end
if lne =3D~ /^Subject: (.*)/
fldSubject =3D $1
end
if lne =3D~ /^Date: (.*)/
fldDate =3D $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 =3D FileDataSource.new("ozemail.inbox")

cnt =3D 0
db =3D SQLite3:atabase.open( "sqllite\\demo.db", :driver =3D> "Native" )
message =3D []
while line =3D dataSource.getLine
if line =3D~ /^From /
cnt+=3D1
processMessage(cnt, db, message)
message =3D []
else
message << line
end
end
db.close

--
Into RFID? www.rfidnewsupdate.com <http://www.rfidnewsupdate.com> Simple,
fast, news.

------=_Part_3627_15219881.1129591760071--


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Email (gmail, MacMail) - delivery report (email opened/read) Elainie Computer Support 3 01-22-2007 10:42 PM
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM
a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewSate is not the class, but the parent, ArrayList leal ting ASP .Net 1 02-10-2004 07:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57