- Mail and web retrieval imaplib, rfc822?

Akhar akhar at videotron.ca
Thu Mar 23 02:09:27 EST 2000


I  can't do a StringIO on the data I receive from the imaplib?? from what I
understand from fiddling with it I can use a
 m.fetch(1, '(RFC822.SIZE BODY[HEADER.FIELDS (DATE)])')
to get the date but it isn't pretty to look at from a web page!!!
I am going crazy here. especially since I found out that pop didn't see my
old mail!! but Imap did
How do I parse the headers?? the body??? in imap
because it tells me that it isn't returning a list?


Matthew Barre <mbarre at mac.com> wrote in message
news:B4FDBB71.1DCF%mbarre at mac.com...
> rfc822 is pretty easy to use...here's an example of how I did it in my
> current project, and thanks to those of you who helped! (I've assumed you
> have downloaded the message and assigned it to a StringIO object, since
your
> input object has to be something similar) :
>
> tempmsg2 = rfc822.Message(tempmsg1)  # create new rfc object from StringIO
> tmpmsg3 = inemsg(tempmsg2)  # assign rfc message to custom inemsg class
>
> class inemsg:
>     def __init__(self,msg):
>         (self.msgfromname, self.msgfrom) = msg.getaddr('from')
>         self.msgto = msg.getaddr('to')
>         self.msgsubject = msg.getheader('subject')
>         self.msgdate = msg.getheader('date')
>         self.msgtext = msg.fp.read()
>
>
> -Matt
> ---------
> "You will find that many of the truths we hold to depend greatly on a
> certain point of view." -Obi Wan Kenobi
>
> > From: "Akhar" <akhar at videotron.ca>
> > Newsgroups: comp.lang.python
> > Date: Mon, 20 Mar 2000 21:55:38 -0800
> > Subject: Mail  and web retrieval imaplib, rfc822?
> >
> > Hi, I have been using this forum a lot lately! Thanks to everyone for
their
> > hel and patience!
> > I have yet another question, but let me do a brief recap!! I want to
make
> > scripts for a web based e-mail reading system, and so I went to use
pop.py
> > and the pop server but as  I later found out while surfing the web and
> > through some hacking pop isn't as flexible as I thought for that sort of
> > service. but my problem now lies in the imaplib. I can see all my
messages
> > (wich by the way are more numerous than pop had found) with uid rangin
from
> > 1 through 10. I thought that converting my scripts from the pop
adventure
> > would be easy, but as it turns out it isn't I had an re.compile() and
for
> > loop to retrieve everyting from the message body to the from and subject
> > headers. But they do not work with the imaplib it tell me that:
> > TypeError: argument 1: expected read-only character buffer, list found
> > I heard about rfc822.py who supposedly handles those pesky headers and
> > message bodies but I can't find a tutorial or example on how to use the
to
> > retrieve the 'from', 'subject', 'Cc' and etc...
> > Also I can't seem to use the uid() command in imaplib ( at least not
> > properly), nor the list() ( it lists everything in my users
/homedirectory
> > wich is where the mailbox is).
> > I just need a few more pointers! Your help has been great!
> > Thank you in advance for any help!
> > Akhar
> >
> >
>





More information about the Python-list mailing list