[Tutor] rfc822.Message

Reggie Dugard reggie@merfinllc.com
Mon Mar 17 10:07:02 2003


Kris,

I believe the problem you're having is that the rfc822.Message
constructor expects an instance of a file object and not a filename.
If you try something like the following I think you'll have better luck.

>>> mailmessage=rfc822.Message(open("2"))


On Sat, 2003-03-15 at 14:24, Kristian Rink wrote:
> Hi all,...
> 
> 
> ...for what I see now, I've ran into some trouble using the rfc822
> module while trying to dissect e-mail messages and to store the
> attachments they're carrying to be able to import them into a
> document management system. Basically, here's what I tried:
> 
> 
> >>> import rfc822
> >>> mailmessage=rfc822.Message("2")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/rfc822.py", line 106, in __init__
>     self.readheaders()
>   File "/usr/lib/python2.2/rfc822.py", line 153, in readheaders
>     line = self.fp.readline()
> AttributeError: 'str' object has no attribute 'readline'
> 
> 
> Btw Message "2" is a mail file inside a MH mail spool directory.
> Basically, it's kinda late now around here and perhaps I'm too tired
> to see the point, but seems I can't get along with this, here. Can
> someone give me a hint what's wrong here?
> 
> TIA, have a nice evening wherever you are...
> Cheers,
> Kris
-- 
Reggie